0
private: delegate System::Void delegate_function(void);

if(this->InvokeRequired)
{
AsyncCallback ^ac = gcnew AsyncCallback(&WCS::MainForm::delegate_function_callback);
delegate_function ^df = gcnew delegate_function(this, &WCS::MainForm::function_to_invoke);

System::IAsyncResult ^asyncresult;

//Begin invoke command here.
try
{
	asyncresult = df->BeginInvoke(ac, df);
	//asyncresult = this->statusLight->BeginInvoke(ac, df);
	//this->commsStatusLight->EndInvoke(asyncresult);
	//df->Invoke();
	df->EndInvoke(asyncresult);
	//df->DynamicInvoke(ac, df);
}
catch (...)
{
	std::cerr << "caught";
}
}

public: System::Void function_to_invoke()
{
	this->statusLight->BackColor = DataClass->getlight();
	this->statusLight1->BackColor = DataClass->getight1();
	this->butCheck->Enabled = DataClass->getenable();
	this->status->Text = DataClass->getstatus();                    //this line returns instead of finishing
	this->status1->Text = DataClass->getstatus1();
}

private: static System::Void delegate_function_callback(System::IAsyncResult ^asyncresult)
{
	//delegate_function ^df = gcnew delegate_function(&WCS::MainForm::function_to_invoke);
                //df->EndInvoke(asyncresult);
}

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.

2
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by Nick Evan
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.