sorry for the question title.
i have problem when using a OPC API.
this API declare a delegate ReadCompleteEventHandler Internally,
somehow in subscription.Read(), it pass ItemValueResult[] into the Mydelegate.
ItemValueResult[] is what i need. I can use it inside ReadCompleteCallback.
however, I am making it into a window form, another class, then trouble comes.
class tester
{
public void Work()
{
ReadCompleteEventHandler Mydelegate = new ReadCompleteEventHandler(ReadCompleteCallback);
subscription.Read(subscription.Items, 123, Mydelegate, out req);
}
static void ReadCompleteCallback(object nn,ItemValueResult[] mm)
{
MessageBox.Show(mm);
}
}
What I have tried:
in tester Class:
public ItemValueResult[] resultinTesterClass;
static void ReadCompleteCallback(object nn,ItemValueResult[]mm)
{
MessageBox.Show(mm);
resultinTesterClass = mm;
}
where in the form1:
public ItemValueResult[] resultinFormClass
private void ButtonRead_Click(object sender, EventArgs e)
{
obj.Work();
resultinFormClass=obj.resultinTesterClass;
}
I think it is too indirect and somethime resultinFormClass return null.
Any conventional way to solve.
thank you!