View | Details | Raw Unified | Return to bug 497175
Collapse All | Expand All

(-)class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs (-2 / +21 lines)
Lines 476-482 Link Here
476
		{
476
		{
477
			AsyncMethodData data = (AsyncMethodData) state;
477
			AsyncMethodData data = (AsyncMethodData) state;
478
			AsyncMethodResult result = data.Result;
478
			AsyncMethodResult result = data.Result;
479
			object ret = data.Method.DynamicInvoke (data.Args);
479
			
480
			object ret;
481
			try {
482
				ret = data.Method.DynamicInvoke (data.Args);
483
			} catch (Exception ex) {
484
				if (result != null) {
485
					result.CompleteWithException (ex);
486
					return;
487
				}
488
				
489
				throw ex;
490
			}
491
		
480
			if (result != null) {
492
			if (result != null) {
481
				result.Complete (ret);
493
				result.Complete (ret);
482
			}
494
			}
Lines 513-519 Link Here
513
525
514
			try {
526
			try {
515
				AsyncMethodResult result = data.Result;
527
				AsyncMethodResult result = data.Result;
516
				object ret = data.Method.DynamicInvoke (data.Args);
528
				object ret;
529
				try {
530
					ret = data.Method.DynamicInvoke (data.Args);
531
				} catch (Exception ex) {
532
					result.CompleteWithException (ex);
533
					return;
534
				}
535
				
517
				result.Complete (ret);
536
				result.Complete (ret);
518
			}
537
			}
519
			finally {
538
			finally {
(-)class/Managed.Windows.Forms/System.Windows.Forms/AsyncMethodResult.cs (-2 / +20 lines)
Lines 34-39 Link Here
34
		private object state;
34
		private object state;
35
		private bool completed;
35
		private bool completed;
36
		private object return_value;
36
		private object return_value;
37
		private Exception exception;
37
38
38
		public AsyncMethodResult ()
39
		public AsyncMethodResult ()
39
		{
40
		{
Lines 68-77 Link Here
68
		public object EndInvoke ()
69
		public object EndInvoke ()
69
		{
70
		{
70
			lock (this) {
71
			lock (this) {
71
				if (completed)
72
				if (completed) {
72
					return return_value;
73
					if (exception == null)
74
						return return_value;
75
					else
76
						throw exception;
77
				}
73
			}
78
			}
74
			handle.WaitOne ();
79
			handle.WaitOne ();
80
			
81
			if (exception != null)
82
				throw exception;
83
				
75
			return return_value;
84
			return return_value;
76
		}
85
		}
77
86
Lines 83-88 Link Here
83
				handle.Set ();
92
				handle.Set ();
84
			}
93
			}
85
		}
94
		}
95
		
96
		public void CompleteWithException (Exception ex)
97
		{
98
			lock (this) {
99
				completed = true;
100
				exception = ex;
101
				handle.Set ();
102
			}
103
		}
86
	}
104
	}
87
105
88
}
106
}

Return to bug 497175