1
哪裏有關於BeginInvoke參數處理的文檔?delegate.BeginInvoke的參數是副本或引用?
如果我有一個接受對象作爲參數的委託(包裝我的處理函數),該對象是否被異步調用的處理函數複製或引用?
delegate void MyDelegate(SomeObject obj);
// later on:
// invoke the delegate async'ly:
new MyDelegate(StaticClass.HandlerFunc).BeginInvoke(objInstance, null, null);
// alter the object:
objInstance.SomeProperty = newValue;
// function:
public static void HandlerFunc(SomeObject obj) {
// is it a possible race condition to read SomeProperty:
if(obj.SomeProperty == oldValue) {
// will possibly never enter?
}
// ... etc.
}