The ManualResetEvent wouldn't be signaled when an exception happens
in the reader loop so we'd deadlock in Read().
I'm still investigating where the exception comes from but this
should at least help unblocking CI.
https://bugzilla.xamarin.com/show_bug.cgi?id=46683
using System;
using System.Collections.Generic;
using System.Threading;
using System;
using System.Collections.Generic;
using System.Threading;
+using System.Runtime.ExceptionServices;
XamlReader r;
XamlNodeQueue q;
bool read_all_done, do_work = true;
XamlReader r;
XamlNodeQueue q;
bool read_all_done, do_work = true;
+ ExceptionDispatchInfo read_exception;
ManualResetEvent wait = new ManualResetEvent (true);
public bool HasLineInfo {
ManualResetEvent wait = new ManualResetEvent (true);
public bool HasLineInfo {
{
if (q.IsEmpty)
wait.WaitOne ();
{
if (q.IsEmpty)
wait.WaitOne ();
+
+ if (read_exception != null)
+ read_exception.Throw ();
+
return q.Reader.Read ();
}
return q.Reader.Read ();
}
if (thread != null)
throw new InvalidOperationException ("Thread has already started");
thread = new Thread (new ParameterizedThreadStart (delegate {
if (thread != null)
throw new InvalidOperationException ("Thread has already started");
thread = new Thread (new ParameterizedThreadStart (delegate {
- while (do_work && r.Read ()) {
- q.Writer.WriteNode (r);
+ try {
+ while (do_work && r.Read ()) {
+ q.Writer.WriteNode (r);
+ wait.Set ();
+ }
+ read_all_done = true;
+ } catch (Exception ex) {
+ read_exception = ExceptionDispatchInfo.Capture (ex);
})) { Name = threadName };
thread.Start ();
}
})) { Name = threadName };
thread.Start ();
}