private void OnXMLSerializing_Completed(IAsyncResult I) { del_xmlSerialized Clone = (del_xmlSerialized)I.AsyncState; Clone.EndInvoke(I); OnSerialized(); }
public void Serialize(System.IO.Stream stream, object o, Type ClassType) { XmlSerializer xx = new XmlSerializer(ClassType); /* ON Serialization Beginning [ONSERIALIZING] */ ds = new del_xmlSerializing(OnXMLSerializing_Begin); IAsyncResult IAR_Begin = ds.BeginInvoke(null, null); ds.EndInvoke(IAR_Begin); /* ON Serialization Beginning [ONSERIALIZING] */ /* ON Serialization Completed ie [ONSERIALIZED] */ dd = new del_xmlSerialized(xx.Serialize); cb = new AsyncCallback(OnXMLSerializing_Completed); IAsyncResult IAR = dd.BeginInvoke(stream, o, cb, dd); // This Delay Is Important Otherwise The Next Line Of Code(From Where Serialize Is Called) // Gets Executed Prior To Conclusion Of EndInvoke, Consequently Throwing Exception. while (IAR.IsCompleted == false) { Thread.Sleep(1); } /* ON Serialization Completed ie [ONSERIALIZED] */ }