I have a stream calculation function that calls a message function from another stream using Invoke, and I want the stream calculation to get a value (valueetype, for example integer) from this message function. How can i do this?
The problem is that I still get the old value of the x variable after Invoke (...), and I expect a value of 15
delegate void mes_del(object param);
void MyThreadFunc()
{
...
int x = 5;
object [] parms = new object []{x};
Invoke(new mes_del(MessageFunc), (object)parms);
...
}
void MessageFunc(object result)
{
int res = 15;
(result as object[])[0] = res;
}
I tried some approaches, such as using object [], object as parameters without success. I, although boxing / unpacking operations should take place in this case, but they do not. Should I use a helper type, as is done in the .NET event mode, and create a mediator object, for example, the owner of the class {public int x; }