Click here to Skip to main content
13,044,543 members (60,033 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 5 Aug 2011

Debugging Cross thread exceptions

, 5 Aug 2011
Rate this:
Please Sign up or sign in to vote.
Recently, I was stuck with following error,
"Cross-thread operation not valid: Control 'label1' accessed from a thread other than the thread it was created on."

The error has been resolved using below code. I am posting it here because it may help someone.
public void SetStatus(string msg)
    if (label1.InvokeRequired)
        label1.Invoke(new MethodInvoker(delegate
            label1.Text = msg;
        label1.Text = msg;

Credits goes to 'IAbstract'. Link :Click here


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


About the Author

Syed Shabeer
Software Developer
India India
A Software programmer. Works on ASP.NET, MVC, VB.NET, C#, .NET Compact framework, SSIS, SQL Server, PHP and its frameworks. Other than that likes to play games in PC.

You may also be interested in...

Comments and Discussions

GeneralReason for my vote of 5 While it may not be debugging, I am ... Pin
Member 822542223-Sep-11 2:17
memberMember 822542223-Sep-11 2:17 
GeneralReason for my vote of 1 sorry for downvoting, but on CP ther... Pin
johannesnestler11-Aug-11 3:17
memberjohannesnestler11-Aug-11 3:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 5 Aug 2011
Article Copyright 2011 by Syed Shabeer
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid