diff options
author | David Karlaš <david.karlas@gmail.com> | 2019-03-05 20:36:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-05 20:36:00 +0300 |
commit | 850b903eb6125f464c20e08a6ec5ddec37ff18ed (patch) | |
tree | 4bbb06e486d72abeb867499ab3d92c981626843e /main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView | |
parent | bf7a7bff67fe4cb28d1ece772128f40acd44ad82 (diff) | |
parent | 2e4129795048e7767f1bdda45a15495e72c47983 (diff) |
Merge pull request #285 from xamarin/dev/davidk/fix801811
Fix 801811: Debugger: tries to evaluate a method instead of showing I…
Diffstat (limited to 'main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView')
-rw-r--r-- | main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/QuickInfo/DebuggerQuickInfoSource.cs | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/QuickInfo/DebuggerQuickInfoSource.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/QuickInfo/DebuggerQuickInfoSource.cs index 25fc5cc394..9313ddf0cd 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/QuickInfo/DebuggerQuickInfoSource.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/QuickInfo/DebuggerQuickInfoSource.cs @@ -51,6 +51,29 @@ namespace MonoDevelop.Debugger.VSTextView.QuickInfo Runtime.RunInMainThread (DestroyWindow).Ignore (); } + static async Task<bool> WaitOneAsync (WaitHandle handle, CancellationToken cancellationToken) + { + RegisteredWaitHandle registeredHandle = null; + var tokenRegistration = default (CancellationTokenRegistration); + try { + var tcs = new TaskCompletionSource<bool> (); + registeredHandle = ThreadPool.RegisterWaitForSingleObject ( + handle, + (state, timedOut) => ((TaskCompletionSource<bool>)state).TrySetResult (!timedOut), + tcs, + int.MaxValue, + true); + tokenRegistration = cancellationToken.Register ( + state => ((TaskCompletionSource<bool>)state).TrySetCanceled (), + tcs); + return await tcs.Task; + } finally { + if (registeredHandle != null) + registeredHandle.Unregister (null); + tokenRegistration.Dispose (); + } + } + public async Task<QuickInfoItem> GetQuickInfoItemAsync (IAsyncQuickInfoSession session, CancellationToken cancellationToken) { if (DebuggingService.CurrentFrame == null) @@ -74,7 +97,11 @@ namespace MonoDevelop.Debugger.VSTextView.QuickInfo var val = DebuggingService.CurrentFrame.GetExpressionValue (debugInfo.Text, options); - if (val == null || val.IsUnknown || val.IsNotSupported) + if (val.IsEvaluating) + await WaitOneAsync (val.WaitHandle, cancellationToken); + if (cancellationToken.IsCancellationRequested) + return null; + if (val == null || val.IsUnknown || val.IsNotSupported || val.IsError) return null; if (!view.Properties.TryGetProperty (typeof (Gtk.Widget), out Gtk.Widget gtkParent)) |