Bee Eee Blog

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:
  1. ANDRE


    CheapTabletsOnline.Com. Canadian Health&Care.No prescription online pharmacy.Special Internet Prices.Best quality drugs. Low price drugs. Order drugs online

    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+….

Leave a Reply

You must be logged in to post a comment.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...