Click here to Skip to main content
15,881,882 members
Articles / Programming Languages / C# 4.0
Alternative
Tip/Trick

Changing a WinForms Control on the 'UI' Thread from another Thread

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
22 Aug 2010CPOL 6.3K   2  
Doing like following for few years now :public void AnyMethod(int parameter){ var wrapper = new Action(()=> { // Do your thing here! }); if (this.InvokeRequired) this.Invoke(wrapper); else wrapper();}
Doing like following for few years now :

public void AnyMethod(int parameter)
{
    var wrapper = new Action(()=>
    {
        // Do your thing here!
    });
    if (this.InvokeRequired)
        this.Invoke(wrapper);
    else
        wrapper();
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Netherlands Netherlands
Engineer Powered by the Cloud

Comments and Discussions

 
-- There are no messages in this forum --