Thread Safe calling to a form
by brian on Jan.03, 2008, under .NET, c#, c# coding GUI, coding
Here is an example of a thread-safe call into a form.
delegate void logCallback(string strLog);
private void log(string log)
{
if (this.InvokeRequired)
{
logCallBack d = new logCallback(log);
this.Invoke(d, log);
}
else
{
this.log( strLog );
}
}
First we determine whether the overhead of an invoke can be dismissed. Then if we must invoke we first create an instance of the delegate. Then we call invoke. That’s it. Not too hard.
1 comment for this entry:
Leave a Reply
You must be logged in to post a comment.

September 8th, 2010 on 10:46 am
Buy:Viagra Soft Tabs.Viagra.Maxaman.Soma.Tramadol.Zithromax.Viagra Super Force.Propecia.Super Active ED Pack.Cialis.Cialis Super Active+.Cialis Professional.VPXL.Cialis Soft Tabs.Levitra.Viagra Professional.Viagra Super Active+….