[Mono-dev] mono xml

Miguel de Icaza miguel at novell.com
Sat Dec 29 12:53:05 EST 2007

> is there any work around for that ? I mean using network stream and
> then use beginread instead of the normal read() method. 

Yes, there is a very simple work around.   If you wrap your code in a
delegate, you can invoke the delegate in async mode.   

So essentially, you can turn any sync operation into an async one.

Here is a simple program that shows you how to use BeginInvoke and
EndInvoke methods (these are automatically generated for all delegates):

using System;
using System.Threading;

delegate int Worker ();
class X {
	static void Main ()
		Worker w = delegate {
			Console.WriteLine ("   Async: sleeping for five seconds");
			Thread.Sleep (5000);
			Console.WriteLine ("   Async: done");
			return 10;
		Console.WriteLine ("Main thread: Launching async method");
		IAsyncResult r = null;

		r = w.BeginInvoke (delegate {
			Console.WriteLine ("   Async: notification Callback invoked, method finished");
			Console.WriteLine ("   Async: result from worker was: {0}", w.EndInvoke (r));
			}, null);
		Console.WriteLine ("Main thread: waiting for async call to finish");
		r.AsyncWaitHandle.WaitOne ();
		Console.WriteLine ("Main thread: finishing");
> the second question is based on an article written in msdn,
> xmltextreader cannot read file above 2GB. why is this limititation
> imposed when it is a forward only reader. or is there any such
> limitation imposed by mono's implementation of the same.

I do not know that there is any limitation in our implementation, let us
know what you find out.


More information about the Mono-devel-list mailing list