0

i have simple code: constructor:

public fList()
{
  InitializeComponent();
  ...
  Task t = new Task ( () => updateBottomStatus() );
  t.Start();

}

updateBottomStatus(){
  this.groupBox1.Enabled = false;
  ... (here is checking mail status, here some class have ~1 sec working time, well i would like to improve my app, well use tasks)
  this.groupBox1.Enabled = true;
}

but when I'm debugging it i have exception style (similar):

wrong operation between threads to control "groupBox" is accessed from a thread other than the thread it was created.

how i can make access near windows form controls in tasks?

cniak
  • 301
  • 2
  • 6
  • 13
  • 1
    You can access the GUI objects only from threads that creates them. – Hamlet Hakobyan Apr 07 '14 at 19:32
  • thanks you! I found some likely similar solved: http://msdn.microsoft.com/en-us/library/ms171728(v=vs.110).aspx?appId=Dev11IDEF1&l=EN-US&k=k(EHInvalidOperation.WinForms.IllegalCrossThreadCall)%3bk(TargetFrameworkMoniker-.NETFramework,Version%3dv4.5)%3bk(DevLang-csharp)&rd=true&cs-save-lang=1&cs-lang=csharp#code-snippet-6 – cniak Apr 07 '14 at 20:00

0 Answers0