0

with IAsyncResult pattern I'm implementing an asynchornous operation.

The signature of the beginning of my invocation is:

object[] data = new object[] {field1,field2};

AsyncSendMessageToSystem caller = SendMessageToSystem;
caller.BeginInvoke(field1,field2,field3, new AsyncCallback(callbackMethod),data);

When the callbackMethod is invoked, it has as input the data object. The field1 var is intended to be modified inside SendMessageToSystem, but callbackMethod will receive original value, and no the updated one.

How could I pass to callback the updated value?

Thanks!

ff8mania
  • 1,553
  • 3
  • 19
  • 28

1 Answers1

0

Did you verify if the callback method is receiving the original value? The way this works is that your callback method gets the reference to the object data, since object[] is a reference type. You need to make sure the modification to field1 happens before the callback is called.

Charles Prakash Dasari
  • 4,964
  • 1
  • 27
  • 46