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

(-)class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs (-5 / +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;
490
			}
491
		
480
			if (result != null) {
492
			if (result != null) {
481
				result.Complete (ret);
493
				result.Complete (ret);
482
			}
494
			}
Lines 511-522 Link Here
511
			}
523
			}
512
#endif
524
#endif
513
525
526
			AsyncMethodResult result = data.Result;
527
			object ret;
528
514
			try {
529
			try {
515
				AsyncMethodResult result = data.Result;
530
				ret = data.Method.DynamicInvoke (data.Args);
516
				object ret = data.Method.DynamicInvoke (data.Args);
517
				result.Complete (ret);
531
				result.Complete (ret);
518
			}
532
			} catch (Exception ex) {
519
			finally {
533
				result.CompleteWithException (ex);
534
				return;
535
			} finally {
520
#if !MWF_ON_MSRUNTIME
536
#if !MWF_ON_MSRUNTIME
521
				if (data.Stack != null) {
537
				if (data.Stack != null) {
522
					// whatever occurs we must revert to the original compressed
538
					// whatever occurs we must revert to the original compressed
(-)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