exception

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2008
Posts: 98
Reputation: Nemoticchigga is an unknown quantity at this point 
Solved Threads: 2
Nemoticchigga Nemoticchigga is offline Offline
Junior Poster in Training

exception

 
0
  #1
May 28th, 2008
  1. private: delegate System::Void delegate_function(void);
  2.  
  3. if(this->InvokeRequired)
  4. {
  5. AsyncCallback ^ac = gcnew AsyncCallback(&WCS::MainForm::delegate_function_callback);
  6. delegate_function ^df = gcnew delegate_function(this, &WCS::MainForm::function_to_invoke);
  7.  
  8. System::IAsyncResult ^asyncresult;
  9.  
  10. //Begin invoke command here.
  11. try
  12. {
  13. asyncresult = df->BeginInvoke(ac, df);
  14. //asyncresult = this->statusLight->BeginInvoke(ac, df);
  15. //this->commsStatusLight->EndInvoke(asyncresult);
  16. //df->Invoke();
  17. df->EndInvoke(asyncresult);
  18. //df->DynamicInvoke(ac, df);
  19. }
  20. catch (...)
  21. {
  22. std::cerr << "caught";
  23. }
  24. }
  25.  
  26. public: System::Void function_to_invoke()
  27. {
  28. this->statusLight->BackColor = DataClass->getlight();
  29. this->statusLight1->BackColor = DataClass->getight1();
  30. this->butCheck->Enabled = DataClass->getenable();
  31. this->status->Text = DataClass->getstatus(); //this line returns instead of finishing
  32. this->status1->Text = DataClass->getstatus1();
  33. }
  34.  
  35. private: static System::Void delegate_function_callback(System::IAsyncResult ^asyncresult)
  36. {
  37. //delegate_function ^df = gcnew delegate_function(&WCS::MainForm::function_to_invoke);
  38. //df->EndInvoke(asyncresult);
  39. }


I am at my wits end with this. The invoke works the first time through, but when all this gets called again, it doesnt get past the line marked above in function_to_invoke. It also throws an exception after the first time. First time works perfect, half works any time after. Please help if you know anything, any advice would be appreciated. Thanks.
Last edited by Nemoticchigga; May 28th, 2008 at 11:53 am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,983
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 308
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Cenosillicaphobiac

Re: exception

 
0
  #2
May 28th, 2008
You've got a question about that are do you just like posting code?
Last edited by niek_e; May 28th, 2008 at 11:51 am.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 98
Reputation: Nemoticchigga is an unknown quantity at this point 
Solved Threads: 2
Nemoticchigga Nemoticchigga is offline Offline
Junior Poster in Training

Re: exception

 
0
  #3
May 28th, 2008
Hit the button too early, I edited it.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,983
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 308
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Cenosillicaphobiac

Re: exception

 
0
  #4
May 28th, 2008
I'm not into windowsprogramming, but shouldn't you dispose() 'df' somewhere before using it again?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 355 | Replies: 3
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC