|
Difficult question. The fact that you are timing the "load" might implicate the "load" itself, making it slower.
Do you need this on the live system or just for dev and/or test environment?
V.
|
|
|
|
|
Use the StopWatch class, call Start() right before and Stop() right after the execution of the code you're interested in.
I don't know what you mean by "load a control"; with all the events going on in a WinForms Form when opening up a new Form, it may well be that your control is touched in the Form's constructor, and several event handlers such as Load and Shown . And that other controls also get handled at around the same time.
You might even have to deal with an extra Control which you handle all at once, using your own run-time code only.
Warning: if lots of data is loaded into the control (such as a DataGridView fed by a database), how you organize the data load will predominate, not the generating and painting of the control itself; unless you have coded a large number of operations on a single control and you've forgotten to make good use of optimizing calls such as Control.SuspendLayout() and the like.
|
|
|
|
|
For a form you can time between the first line of the constructor and when the Load event[^] gets fired.
|
|
|
|
|
hi guys
can i get Collection from object if it is part of it?
code should look something like this
public class SomeCollection : CollectionBase
{
public void Add(SomeClass sc)
{
this.List.Add(sc);
}
}
class SomeClass
{
public bool AmIPartOfCollection
{
get
{
}
}
public SomeCollection MyCollection
{
get
{
}
}
}
void Main()
{
SomeClass temp = new SomeClass();
SomeCollection sc = new SomeCollection();
sc.Add(temp);
}
|
|
|
|
|
Not with a standard collection, no. It's pretty straightforward to write a specialised collection and interface for member objects to do this.
However, in most situations you know roughly where the object must be, so you can use targetCollection.Contains.
|
|
|
|
|
Hanzaplast wrote: public SomeCollection MyCollection
Hanzaplast wrote:
you can't do that in general as an object may be part of more than one collection.
|
|
|
|
|
Damn! Beat me to it...
My 5.
|
|
|
|
|
you could have suggested a
public List<SomeCollection> MyCollections {get;}
|
|
|
|
|
The inference I take from your answer, Luc (the answer seems "intuitively" correct to me), is that you could then iterate MyCollections, and, for each Collection in MyCollection, test for the presence of a specifc object using 'Contains. This solution also seeming to allow for the idea that you could also, then ... in the case of an object being a member of more than one Collection ... return a List of all Collections it was a member in, as well.
However, I do think the OP's code is pretty weird. If you are going to add any type of object to a collection: that would seem to indicate a need to me for a generic (even "dynamic," late-bound ?) solution.
thanks, Bill
"It is the mark of an educated mind to be able to entertain a thought without accepting it." Aristotle
|
|
|
|
|
hi all..
i am using script task in SSIS.i am new to it.
I have a oracle connection string in the code say:
now i want to access this conection via variable: OraConn. how to do it?
is it like below?
OraConn.ConnectionString = Dts.Variables["OraConn"].Value.ToString();
but its not working can anybdy suggest?
FBG
modified 19-Jan-12 8:56am.
|
|
|
|
|
bigphish wrote: but its not working
Without some more information it's impossible even to make a guess.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi All,
First off I am new to C# so please forgive me if I ask obvious questions.
I am required to write code that will communicate with a SOAP based web service hosted by a third party. I have imported the provided WSDL using wsdl.exe and implemented the generated code in my program. This successfully generates the required SOAP request with the correctly structured XML contained in the body. I have working XML/SOAP samples that I have successfully used to get the expected response from the service via a small Delphi test application so I know how the structure of the call must look.
The C# generated call (captured using Fiddler) is almost the same as the samples however there are two additional tags in the samples that are not in my generated call. These tags are the first two tags in the SOAP body after which the rest of the XML is correct.
My question is how do I (or can I at all) add these tags at run time to the generated message?
I hope this is enough information but please let me know if I need to provide more.
Kind Regards,
Francois
|
|
|
|
|
Shew, no a single reply... I hope I haven't broken a rule or committed some other faux pas.
|
|
|
|
|
Hi,
Actuially Iam using vs2010. My requirement is simple. Once the user click on listview-header then its
visible has set to false.
Currently Iam using the below codes, and its fine...No problem...
<pre>
listView1.ColumnClick += new ColumnClickEventHandler(this.MyLstVw_Vsble)
private void MyLstVw_Vsble(object Sender, EventArgs e)
{
listView1.Visible = false;
}
But my clarification is, why not assigning the controls visible property, directly like the below.
listView1.ColumnClick += listView1.Visible = true;
Is it possible?...
Thanks
|
|
|
|
|
Paramu1973 wrote: But my clarification is, why not assigning the controls visible property, directly like the below.
listView1.ColumnClick += listView1.Visible = true;
No, that's not possible. ColumnClick points to an event, not to a line of code. You could use an anonymous delegate though.
listView1.ColumnClick += delegate { listView1.Visible = true; };
Enjoy
Bastard Programmer from Hell
|
|
|
|
|
Thanks Eddy
|
|
|
|
|
You're welcome
|
|
|
|
|
ColumnClick is an event, so you have to use += with a delegate reference. Depending on the version of .Net you have, there are several ways to do that:
- All versions: explicit new expression as in your example.
- .Net 2+: implicit cast of a method name (listView1.ColumnClick += MyLstVs_Vsble)
- .Net 2+: anonymous delegate (see the post above this one)
- .Net 3+: lambda function: listView1.ColumnClick += (s, e) => listView1.Visible = false;
The last is the closest way so far of assigning an expression directly to a delegate.
|
|
|
|
|
|
Hi guys
After reading some MSDN I still have some things I don't understand.
Having an application with the folowing structure
class MainApplication (thread handling UI controls)
class CModuleA -> (starts a thread thWorkerA)
class CModuleB -> start a thread thWorkerB
here are my questions:
1. From thWorkerB I raise an event intended to be caught by subscriber CModuleA class.
Inside CModuleA it is the handling event funtion.
The execution of the thWorkerB thread remain blocked inside the eventHandling function from CModuleA until it finishes?
2. How is exactly this send event handled? In what context is it done?
3. The Invoke method should be used to execute delegates on the current UI thread, which chage controls.
This Invoke function could be used in other cases, not involving UI controls? (similar situations)
modified 19-Jan-12 4:05am.
|
|
|
|
|
1. From thWorkerB I raise an event intended to be caught by subscriber CModuleA class.
Inside CModuleA it is the handling event funtion.
The execution of the thWorkerB thread remain blocked inside the eventHandling function from CModuleA until it finishes?
Yes. Unless you delegate execution to another thread, event handlers run in the thread from which you called them. An event handler should never do anything which will take a long time for this reason (except in cases where you are happy for that component to have its queue stalled); you should post messages onto a queue which is handled by another thread, or something similar, and return as quickly as possible.
2. How is exactly this send event handled? In what context is it done?
Methods called through a delegate are in the same execution context as the method from which they were called, similar to a normal method call.
3. You can use Invoke to execute across threads if you have a Control to call it on, or you have a Dispatcher to hand (WPF). If you don't want it to still block, though, you should use BeginInvoke (generally you can do a fire-and-forget and not bother with EndInvoke as you don't need the return value).
In a pure component situation, where you don't have any UI related infrastructure, you should handle the cross thread execution yourself. As I mentioned above, a good way to do this is to have a thread which watches a queue, and have the event handler post a message onto the queue for the handler thread to deal with. You can use WaitHandles (i.e. AutoResetEvent) to notify the thread that it should wake up without doing 'hot waiting' (i.e. checking the queue in a loop).
Alternatively you can spawn new tasks and push them into a ThreadPool or, if using .Net 4, use the Task Parallel classes in the Framework. Both of these mechanisms essentially run a queue and multiple handling threads pulling tasks off them.
|
|
|
|
|
ok, thanks!
Still I am wondering how this messaging(event sending) between classes is implemented.
(like a function call, or like messaging in a separate thread or context)
but this is not so important.
|
|
|
|
|
Hi
I'm having a weird bug in my application. This is my first time in this forum I hope you can help me because this bug is making me crazy.
It's a desktop application where I have a form with some MaskedTextBox in it. The goal of these text boxes is allow the user to introduce values with format "000.000".
When the user modifies the textbox, the value is stored in a internal variable and until then everything works fine. The problem appear when the application reloads the textbox control from the variable. In my computer the value is retrieved correctly, the application shows in the text box the same value the user has introduced before, but in some computers the value is retrieved wrong. For instance, the user inserts 001.000 and when the application reloads the control, the value updates to 100.000.
First time I thought that it would be a Culture issue, but the user uses the same as mine (es-ES) and I have included information about culture in the code (invariant culture). This is the definition of the textbox:
this.tbxFrequency10.Culture = new System.Globalization.CultureInfo("");
this.tbxFrequency10.Location = new System.Drawing.Point(177, 254);
this.tbxFrequency10.Mask = "000.000";
this.tbxFrequency10.Name = "tbxFrequency10";
this.tbxFrequency10.PromptChar = '0';
this.tbxFrequency10.Size = new System.Drawing.Size(135, 20);
this.tbxFrequency10.TabIndex = 116;
this.tbxFrequency10.TextMaskFormat = System.Windows.Forms.MaskFormat.IncludePromptAndLiterals;
this.tbxFrequency10.Validated += new System.EventHandler(this.Control_Validated);
The main problem here is I can't reproduce the bug the user has. Just in case I changed my Windows regional configuration in order to try to reproduce the bug but with no success. Anyone has an idea about what could be the reason of this bug?
Thanks in advance. Sorry for my english.
Regards,
|
|
|
|
|
The behavior is by design[^];
MSDN states: "." -> Decimal placeholder. The actual display character used will be the decimal symbol appropriate to the format provider, as determined by the control's FormatProvider property.
Bastard Programmer from Hell
|
|
|
|
|
Where is the code that stores and restores the value? (Or the data binding definition, if you have bound the text box?)
You should use CultureInfo.InvariantCulture not new CultureInfo(""), but that is unlikely to be the source of the problem.
|
|
|
|