Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.ClassOutline/CSharpOutlineTextEditorExtension.cs2
-rw-r--r--main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/DialogFileReplacePolicy.cs6
-rw-r--r--main/src/addins/MacPlatform/MacProxyCredentialProvider.cs4
-rw-r--r--main/src/addins/MacPlatform/MainToolbar/CenteringSpace.cs5
-rw-r--r--main/src/addins/MacPlatform/MainToolbar/MainToolbar.cs8
-rw-r--r--main/src/addins/MacPlatform/MainToolbar/SearchBar.cs4
-rw-r--r--main/src/addins/MacPlatform/MainToolbar/SelectorView.cs2
-rw-r--r--main/src/addins/MacPlatform/MainToolbar/StatusBar.cs6
-rw-r--r--main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/CustomSoftDebuggerEngine.cs2
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebuggingService.cs24
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/PinnedWatchStore.cs2
-rw-r--r--main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/Toolbox.cs2
-rw-r--r--main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/CodeBehindWriter.cs8
-rw-r--r--main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ToolboxService.cs2
-rw-r--r--main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs26
-rw-r--r--main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs2
-rw-r--r--main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ToolboxLoader.cs7
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/UpdateAllPackagesInProjectHandler.cs57
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/UpdateAllPackagesInSolutionHandler.cs59
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackagesDialog.cs2
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectPackagesProjectNodeBuilderExtension.cs2
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/BackgroundPackageActionRunner.cs2
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopProjectSystem.cs9
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageCompatibilityChecker.cs57
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEventsMonitor.cs2
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementFileService.cs4
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProgressProvider.cs57
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProjectOperations.cs69
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRestoreRunner.cs2
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProgressMonitorExtensions.cs2
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ThreadSafePackageManagementEvents.cs4
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackagesInSolution.cs2
-rw-r--r--main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.Commands/WebReferenceCommandHandler.cs11
-rw-r--r--main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences/WebReferencesService.cs5
-rw-r--r--main/src/addins/MonoDeveloperExtensions/Commands.cs4
-rw-r--r--main/src/addins/NUnit/Gui/TestResultsPad.cs14
-rw-r--r--main/src/addins/NUnit/Services/NUnitAssemblyTestSuite.cs2
-rw-r--r--main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs3
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/Commands.cs2
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitCredentials.cs20
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs8
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitService.cs4
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.Gui/WorkingCopyFormatDialog.cs4
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs2
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/StatusView.cs2
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/VersionControlDocumentInfo.cs4
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/CheckoutCommand.cs2
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs8
-rw-r--r--main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/StatusBar.xaml.cs2
-rw-r--r--main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/WPFToolbar.cs5
-rw-r--r--main/src/addins/WindowsPlatform/WindowsPlatform/WindowsProxyCredentialProvider.cs4
-rw-r--r--main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs2
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestSession.cs6
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchResult.cs5
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/StatusArea.cs10
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ToolsCommands.cs3
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CustomTools/CustomToolService.cs2
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution/ExecutionModeCommandService.cs9
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchProgressMonitor.cs10
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/MultiTaskProgressDialog.cs2
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/DefaultMonitorPad.cs4
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/GtkSynchronizationContext.cs53
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/GuiSyncContext.cs8
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/MonoDevelopStatusBar.cs2
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SyncContext.cs217
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.ProgressMonitoring/MessageDialogProgressMonitor.cs2
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.ProgressMonitoring/MultiTaskDialogProgressMonitor.cs2
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj1
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DispatchService.cs114
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs2
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/MessageService.cs4
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs4
72 files changed, 346 insertions, 664 deletions
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.ClassOutline/CSharpOutlineTextEditorExtension.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.ClassOutline/CSharpOutlineTextEditorExtension.cs
index f26821ec2d..546be6ad18 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.ClassOutline/CSharpOutlineTextEditorExtension.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.ClassOutline/CSharpOutlineTextEditorExtension.cs
@@ -301,7 +301,7 @@ namespace MonoDevelop.CSharp.ClassOutline
bool RefillOutlineStore ()
{
- DispatchService.AssertGuiThread ();
+ Runtime.AssertMainThread ();
Gdk.Threads.Enter ();
refreshingOutline = false;
if (outlineTreeStore == null || !outlineTreeView.IsRealized) {
diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/DialogFileReplacePolicy.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/DialogFileReplacePolicy.cs
index 3d9f2fda4e..1552b656cb 100644
--- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/DialogFileReplacePolicy.cs
+++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/DialogFileReplacePolicy.cs
@@ -27,7 +27,7 @@
//
using System;
-
+using MonoDevelop.Core;
using MonoDevelop.Deployment;
using MonoDevelop.Ide;
@@ -58,10 +58,10 @@ namespace MonoDevelop.Deployment.Gui
//IFileReplacePolicy is not likely to be running in the GUI thread
//so use some DispatchService magic to synchronously call the dialog in the GUI thread
- DispatchService.GuiSyncDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
using (var dialog = new FileReplaceDialog (response, source, sourceModified.ToString (), target, targetModified.ToString ()))
response = (FileReplaceDialog.ReplaceResponse) MessageService.ShowCustomDialog (dialog);
- });
+ }).Wait ();
switch (response) {
case FileReplaceDialog.ReplaceResponse.Replace:
diff --git a/main/src/addins/MacPlatform/MacProxyCredentialProvider.cs b/main/src/addins/MacPlatform/MacProxyCredentialProvider.cs
index 9ccc5d79d7..8b929b78d9 100644
--- a/main/src/addins/MacPlatform/MacProxyCredentialProvider.cs
+++ b/main/src/addins/MacPlatform/MacProxyCredentialProvider.cs
@@ -98,7 +98,7 @@ namespace MonoDevelop.MacIntegration
{
NetworkCredential result = null;
- DispatchService.GuiSyncDispatch (() => {
+ Runtime.RunInMainThread (() => {
using (var ns = new NSAutoreleasePool ()) {
var message = credentialType == CredentialType.ProxyCredentials
@@ -163,7 +163,7 @@ namespace MonoDevelop.MacIntegration
var password = passwordInput.StringValue;
result = new NetworkCredential (username, password);
}
- });
+ }).Wait ();
// store the obtained credentials in the keychain
// but don't store for the root url since it may have other credentials
diff --git a/main/src/addins/MacPlatform/MainToolbar/CenteringSpace.cs b/main/src/addins/MacPlatform/MainToolbar/CenteringSpace.cs
index 4684c43565..26fa1d872a 100644
--- a/main/src/addins/MacPlatform/MainToolbar/CenteringSpace.cs
+++ b/main/src/addins/MacPlatform/MainToolbar/CenteringSpace.cs
@@ -27,6 +27,7 @@ using System;
using AppKit;
using CoreGraphics;
using Foundation;
+using MonoDevelop.Core;
using MonoDevelop.Ide;
namespace MonoDevelop.MacIntegration.MainToolbar
@@ -43,12 +44,12 @@ namespace MonoDevelop.MacIntegration.MainToolbar
public override void ViewDidMoveToWindow ()
{
NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidResizeNotification, notif =>
- DispatchService.GuiDispatch (toolbarItem.UpdateWidth));
+ Runtime.RunInMainThread (() => toolbarItem.UpdateWidth ()));
NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.WillEnterFullScreenNotification, notif =>
CenteringSpaceToolbarItem.WindowFullscreening = true);
NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidEnterFullScreenNotification, notif => {
CenteringSpaceToolbarItem.WindowFullscreening = false;
- DispatchService.GuiDispatch (toolbarItem.UpdateWidth);
+ Runtime.RunInMainThread (() => toolbarItem.UpdateWidth ());
});
base.ViewDidMoveToWindow ();
diff --git a/main/src/addins/MacPlatform/MainToolbar/MainToolbar.cs b/main/src/addins/MacPlatform/MainToolbar/MainToolbar.cs
index 3a3bf90904..0a9ff4a042 100644
--- a/main/src/addins/MacPlatform/MainToolbar/MainToolbar.cs
+++ b/main/src/addins/MacPlatform/MainToolbar/MainToolbar.cs
@@ -148,7 +148,7 @@ namespace MonoDevelop.MacIntegration.MainToolbar
};
IDisposable resizeTimer = null;
- NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.WillStartLiveResizeNotification, notif => DispatchService.GuiDispatch (() => {
+ NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.WillStartLiveResizeNotification, notif => Runtime.RunInMainThread (() => {
if (!IsCorrectNotification (selector, notif.Object))
return;
@@ -162,7 +162,7 @@ namespace MonoDevelop.MacIntegration.MainToolbar
});
}));
- NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidResizeNotification, notif => DispatchService.GuiDispatch (() => {
+ NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidResizeNotification, notif => Runtime.RunInMainThread (() => {
if (!IsCorrectNotification (selector, notif.Object))
return;
@@ -171,7 +171,7 @@ namespace MonoDevelop.MacIntegration.MainToolbar
selector.RequestResize ();
}));
- NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidEndLiveResizeNotification, notif => DispatchService.GuiDispatch (() => {
+ NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidEndLiveResizeNotification, notif => Runtime.RunInMainThread (() => {
if (!IsCorrectNotification (selector, notif.Object))
return;
@@ -274,7 +274,7 @@ namespace MonoDevelop.MacIntegration.MainToolbar
MaxSize = new CGSize (360, 22),
};
- Action<NSNotification> resizeAction = notif => DispatchService.GuiDispatch (() => {
+ Action<NSNotification> resizeAction = notif => Runtime.RunInMainThread (() => {
// Skip updates with a null Window. Only crashes on Mavericks.
// The View gets updated once again when the window resize finishes.
if (bar.Window == null)
diff --git a/main/src/addins/MacPlatform/MainToolbar/SearchBar.cs b/main/src/addins/MacPlatform/MainToolbar/SearchBar.cs
index cb1037a0e3..565fffba40 100644
--- a/main/src/addins/MacPlatform/MainToolbar/SearchBar.cs
+++ b/main/src/addins/MacPlatform/MainToolbar/SearchBar.cs
@@ -72,7 +72,7 @@ namespace MonoDevelop.MacIntegration.MainToolbar
void Initialize ()
{
- NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidResignKeyNotification, notification => DispatchService.GuiDispatch (() => {
+ NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidResignKeyNotification, notification => Runtime.RunInMainThread (() => {
var other = (NSWindow)notification.Object;
LogMessage ($"Lost focus from resign key: {other.DebugDescription}.");
@@ -81,7 +81,7 @@ namespace MonoDevelop.MacIntegration.MainToolbar
LostFocus (this, null);
}
}));
- NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidResizeNotification, notification => DispatchService.GuiDispatch (() => {
+ NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidResizeNotification, notification => Runtime.RunInMainThread (() => {
var other = (NSWindow)notification.Object;
LogMessage ($"Lost focus from resize: {other.DebugDescription}.");
if (notification.Object == Window) {
diff --git a/main/src/addins/MacPlatform/MainToolbar/SelectorView.cs b/main/src/addins/MacPlatform/MainToolbar/SelectorView.cs
index 21b7f938d0..e7581a9b6a 100644
--- a/main/src/addins/MacPlatform/MainToolbar/SelectorView.cs
+++ b/main/src/addins/MacPlatform/MainToolbar/SelectorView.cs
@@ -327,7 +327,7 @@ namespace MonoDevelop.MacIntegration.MainToolbar
base.ViewDidMoveToWindow ();
NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidChangeBackingPropertiesNotification,
- notification => DispatchService.GuiDispatch (RealignTexts));
+ notification => Runtime.RunInMainThread ((Action) RealignTexts));
RealignTexts ();
}
diff --git a/main/src/addins/MacPlatform/MainToolbar/StatusBar.cs b/main/src/addins/MacPlatform/MainToolbar/StatusBar.cs
index cf9f3a4824..4948163b90 100644
--- a/main/src/addins/MacPlatform/MainToolbar/StatusBar.cs
+++ b/main/src/addins/MacPlatform/MainToolbar/StatusBar.cs
@@ -167,7 +167,7 @@ namespace MonoDevelop.MacIntegration.MainToolbar
wc++;
}
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
if (ec > 0) {
buildResultVisible = true;
buildResultText.AttributedString = new NSAttributedString (ec.ToString (), foregroundColor: NSColor.Text,
@@ -197,7 +197,7 @@ namespace MonoDevelop.MacIntegration.MainToolbar
TaskService.Errors.TasksAdded += updateHandler;
TaskService.Errors.TasksRemoved += updateHandler;
- NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidChangeBackingPropertiesNotification, notif => DispatchService.GuiDispatch (() => {
+ NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidChangeBackingPropertiesNotification, notif => Runtime.RunInMainThread (() => {
if (Window == null)
return;
@@ -450,7 +450,7 @@ namespace MonoDevelop.MacIntegration.MainToolbar
public void ShowMessage (IconId image, string message, bool isMarkup, NSColor color)
{
- DispatchService.AssertGuiThread ();
+ Runtime.AssertMainThread ();
bool changed = LoadText (message, isMarkup, color);
LoadPixbuf (image);
diff --git a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/CustomSoftDebuggerEngine.cs b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/CustomSoftDebuggerEngine.cs
index c5f37354a0..65ad712d29 100644
--- a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/CustomSoftDebuggerEngine.cs
+++ b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/CustomSoftDebuggerEngine.cs
@@ -80,7 +80,7 @@ namespace MonoDevelop.Debugger.Soft
static T InvokeSynch<T> (Func<T> func)
{
- if (MonoDevelop.Ide.DispatchService.IsGuiThread)
+ if (Runtime.IsMainThread)
return func ();
var ev = new System.Threading.ManualResetEvent (false);
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebuggingService.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebuggingService.cs
index dfc399f9dd..9991801685 100644
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebuggingService.cs
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebuggingService.cs
@@ -385,7 +385,7 @@ namespace MonoDevelop.Debugger
cancelRegistration = console.CancellationToken.Register (Stop);
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
if (DebugSessionStarted != null)
DebugSessionStarted (null, EventArgs.Empty);
NotifyLocationChanged ();
@@ -434,7 +434,7 @@ namespace MonoDevelop.Debugger
currentConsole.Dispose ();
}
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
HideExceptionCaughtDialog ();
if (currentIcon != null) {
@@ -457,23 +457,23 @@ namespace MonoDevelop.Debugger
static void UnsetDebugLayout ()
{
// Dispatch synchronously to avoid start/stop races
- DispatchService.GuiSyncDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
IdeApp.Workbench.HideCommandBar ("Debug");
if (IdeApp.Workbench.CurrentLayout == "Debug") {
IdeApp.Workbench.CurrentLayout = oldLayout ?? "Solution";
}
oldLayout = null;
- });
+ }).Wait ();
}
static void SetDebugLayout ()
{
// Dispatch synchronously to avoid start/stop races
- DispatchService.GuiSyncDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
oldLayout = IdeApp.Workbench.CurrentLayout;
IdeApp.Workbench.CurrentLayout = "Debug";
IdeApp.Workbench.ShowCommandBar ("Debug");
- });
+ }).Wait ();
}
public static bool IsDebugging {
@@ -705,7 +705,7 @@ namespace MonoDevelop.Debugger
static void OnBusyStateChanged (object s, BusyStateEventArgs args)
{
isBusy = args.IsBusy;
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
busyDialog.UpdateBusyState (args);
if (args.IsBusy) {
if (busyStatusIcon == null) {
@@ -737,7 +737,7 @@ namespace MonoDevelop.Debugger
nextStatementLocations.Clear ();
currentBacktrace = null;
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
HideExceptionCaughtDialog ();
if (ResumedEvent != null)
ResumedEvent (null, a);
@@ -785,7 +785,7 @@ namespace MonoDevelop.Debugger
static void NotifyPaused ()
{
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
if (PausedEvent != null)
PausedEvent (null, EventArgs.Empty);
NotifyLocationChanged ();
@@ -796,7 +796,7 @@ namespace MonoDevelop.Debugger
static void NotifyException (TargetEventArgs args)
{
if (args.Type == TargetEventType.UnhandledException || args.Type == TargetEventType.ExceptionThrown) {
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
if (CurrentFrame != null) {
ShowExceptionCaughtDialog ();
}
@@ -913,7 +913,7 @@ namespace MonoDevelop.Debugger
set {
if (currentBacktrace != null && value < currentBacktrace.FrameCount) {
currentFrame = value;
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
NotifyCurrentFrameChanged ();
});
}
@@ -940,7 +940,7 @@ namespace MonoDevelop.Debugger
else
currentFrame = -1;
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
NotifyCallStackChanged ();
NotifyCurrentFrameChanged ();
NotifyLocationChanged ();
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/PinnedWatchStore.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/PinnedWatchStore.cs
index 4d9bc48f2f..52ac37e34e 100644
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/PinnedWatchStore.cs
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/PinnedWatchStore.cs
@@ -272,7 +272,7 @@ namespace MonoDevelop.Debugger
batchChanged.Add (watch);
return;
}
- DispatchService.GuiDispatch (() => {
+ Runtime.RunInMainThread (() => {
if (WatchChanged != null)
WatchChanged (this, new PinnedWatchEventArgs (watch));
});
diff --git a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/Toolbox.cs b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/Toolbox.cs
index 6258a1768d..23dccd0463 100644
--- a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/Toolbox.cs
+++ b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/Toolbox.cs
@@ -228,7 +228,7 @@ namespace MonoDevelop.DesignerSupport.Toolbox
public void Refresh ()
{
// GUI assert here is to catch Bug 434065 - Exception while going to the editor
- DispatchService.AssertGuiThread ();
+ Runtime.AssertMainThread ();
if (toolboxService.Initializing) {
toolboxWidget.CustomMessage = GettextCatalog.GetString ("Initializing...");
diff --git a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/CodeBehindWriter.cs b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/CodeBehindWriter.cs
index 3b025914ed..3f8fbdeb1c 100644
--- a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/CodeBehindWriter.cs
+++ b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/CodeBehindWriter.cs
@@ -84,11 +84,11 @@ namespace MonoDevelop.DesignerSupport
openFiles = new List<string> ();
if (!IdeApp.IsInitialized)
return openFiles;
- DispatchService.GuiSyncDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
foreach (var doc in IdeApp.Workbench.Documents)
if (doc.Editor != null)
openFiles.Add (doc.FileName);
- });
+ }).Wait ();
}
return openFiles;
}
@@ -175,7 +175,7 @@ namespace MonoDevelop.DesignerSupport
}
//these documents are open, so needs to run in GUI thread
- DispatchService.GuiSyncDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
foreach (KeyValuePair<FilePath, string> item in filesToWrite) {
try {
@@ -213,7 +213,7 @@ namespace MonoDevelop.DesignerSupport
LoggingService.LogError ("CodeBehindWriter failed", ex);
}
}
- });
+ }).Wait ();
filesToWrite = null;
}
diff --git a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ToolboxService.cs b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ToolboxService.cs
index 0d802499f4..68c6ddf7f8 100644
--- a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ToolboxService.cs
+++ b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ToolboxService.cs
@@ -184,7 +184,7 @@ namespace MonoDevelop.DesignerSupport
ctx.Dispose ();
}
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
AddUserItems (nodes);
initializing--;
SaveConfiguration ();
diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs
index 2638aada29..2f2e4c8591 100644
--- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs
+++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs
@@ -117,7 +117,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder
if (System.IO.File.Exists (fileName)) {
watcher.Path = Path.GetDirectoryName (fileName);
watcher.Filter = Path.GetFileName (fileName);
- watcher.Changed += DispatchService.GuiDispatchDelegate (new FileSystemEventHandler (OnSteticFileChanged));
+ watcher.Changed += OnSteticFileChanged;
watcher.EnableRaisingEvents = true;
}
}
@@ -161,17 +161,19 @@ namespace MonoDevelop.GtkCore.GuiBuilder
void OnSteticFileChanged (object s, FileSystemEventArgs args)
{
- lock (fileSaveLock) {
- if (lastSaveTime == System.IO.File.GetLastWriteTime (fileName))
- return;
- }
-
- if (GuiBuilderService.HasOpenDesigners (project, true)) {
- if (MessageService.AskQuestion (GettextCatalog.GetString ("The project '{0}' has been modified by an external application. Do you want to reload it?", project.Name), GettextCatalog.GetString ("Unsaved changes in the open GTK designers will be lost."), AlertButton.Cancel, AlertButton.Reload) != AlertButton.Reload)
- return;
- }
- if (!disposed)
- Reload ();
+ Runtime.RunInMainThread (() => {
+ lock (fileSaveLock) {
+ if (lastSaveTime == System.IO.File.GetLastWriteTime (fileName))
+ return;
+ }
+
+ if (GuiBuilderService.HasOpenDesigners (project, true)) {
+ if (MessageService.AskQuestion (GettextCatalog.GetString ("The project '{0}' has been modified by an external application. Do you want to reload it?", project.Name), GettextCatalog.GetString ("Unsaved changes in the open GTK designers will be lost."), AlertButton.Cancel, AlertButton.Reload) != AlertButton.Reload)
+ return;
+ }
+ if (!disposed)
+ Reload ();
+ });
}
public void Reload ()
diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs
index 2c2f22d28a..b511d9fd7e 100644
--- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs
+++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs
@@ -113,7 +113,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder
public static Stetic.Application SteticApp {
get {
// Stetic is not thread safe, so all has to be done in the gui thread
- DispatchService.AssertGuiThread ();
+ Runtime.AssertMainThread ();
if (steticApp == null) {
steticApp = Stetic.ApplicationFactory.CreateApplication (Stetic.IsolationMode.None);
steticApp.AllowInProcLibraries = false;
diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ToolboxLoader.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ToolboxLoader.cs
index 1cb98ff733..78ca552c89 100644
--- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ToolboxLoader.cs
+++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ToolboxLoader.cs
@@ -58,11 +58,10 @@ namespace MonoDevelop.GtkCore.GuiBuilder
}
List<ItemToolboxNode> list = new List<ItemToolboxNode> ();
- ComponentType[] types = null;
- DispatchService.GuiSyncDispatch (delegate {
+ var types = Runtime.RunInMainThread (delegate {
// Stetic is not thread safe, it has to be used from the gui thread
- types = GuiBuilderService.SteticApp.GetComponentTypes (filename);
- });
+ return GuiBuilderService.SteticApp.GetComponentTypes (filename);
+ }).Result;
foreach (ComponentType ct in types) {
if (ct.Category == "window")
continue;
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/UpdateAllPackagesInProjectHandler.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/UpdateAllPackagesInProjectHandler.cs
index 25b779b780..ce70af4f70 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/UpdateAllPackagesInProjectHandler.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/UpdateAllPackagesInProjectHandler.cs
@@ -1,36 +1,37 @@
-//
-// UpdateAllPackagesInProjectHandler.cs
-//
-// Author:
-// Matt Ward <matt.ward@xamarin.com>
-//
-// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
+//
+// UpdateAllPackagesInProjectHandler.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
using System;
using System.Collections.Generic;
using System.Linq;
using MonoDevelop.PackageManagement;
using MonoDevelop.Components.Commands;
using MonoDevelop.Ide;
-
+using MonoDevelop.Core;
+
namespace MonoDevelop.PackageManagement.Commands
{
public class UpdateAllPackagesInProjectHandler : PackagesCommandHandler
@@ -40,7 +41,7 @@ namespace MonoDevelop.PackageManagement.Commands
try {
IPackageManagementProject project = PackageManagementServices.Solution.GetActiveProject ();
RestoreBeforeUpdateAction.Restore (project, () => {
- DispatchService.GuiSyncDispatch (() => Update (project));
+ Runtime.RunInMainThread (() => Update (project)).Wait ();
});
} catch (Exception ex) {
ShowStatusBarError (ex);
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/UpdateAllPackagesInSolutionHandler.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/UpdateAllPackagesInSolutionHandler.cs
index 035126352f..e6b0d0d4bb 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/UpdateAllPackagesInSolutionHandler.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/UpdateAllPackagesInSolutionHandler.cs
@@ -1,36 +1,37 @@
-//
-// UpdateAllPackagesInSolutionCommandHandler.cs
-//
-// Author:
-// Matt Ward <matt.ward@xamarin.com>
-//
-// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
+//
+// UpdateAllPackagesInSolutionCommandHandler.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
using System;
using System.Collections.Generic;
using System.Linq;
using MonoDevelop.PackageManagement;
using MonoDevelop.Components.Commands;
using MonoDevelop.Ide;
-
+using MonoDevelop.Core;
+
namespace MonoDevelop.PackageManagement.Commands
{
public class UpdateAllPackagesInSolutionHandler : PackagesCommandHandler
@@ -41,9 +42,9 @@ namespace MonoDevelop.PackageManagement.Commands
UpdateAllPackagesInSolution updateAllPackages = CreateUpdateAllPackagesInSolution ();
ProgressMonitorStatusMessage progressMessage = ProgressMonitorStatusMessageFactory.CreateUpdatingPackagesInSolutionMessage (updateAllPackages.Projects);
RestoreBeforeUpdateAction.Restore (updateAllPackages.Projects, () => {
- DispatchService.GuiSyncDispatch (() => {
+ Runtime.RunInMainThread (() => {
Update (updateAllPackages, progressMessage);
- });
+ }).Wait ();
});
} catch (Exception ex) {
ProgressMonitorStatusMessage progressMessage = ProgressMonitorStatusMessageFactory.CreateUpdatingPackagesInSolutionMessage ();
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackagesDialog.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackagesDialog.cs
index cf20c9755d..22c835f102 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackagesDialog.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackagesDialog.cs
@@ -454,7 +454,7 @@ namespace MonoDevelop.PackageManagement
{
// Put it back on the GUI thread so the correct synchronization context
// is used. The image loading will be done on a background thread.
- DispatchService.GuiDispatch (() => imageLoader.LoadFrom (iconUrl, row));
+ Runtime.RunInMainThread (() => imageLoader.LoadFrom (iconUrl, row));
}
bool IsOddRow (int row)
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectPackagesProjectNodeBuilderExtension.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectPackagesProjectNodeBuilderExtension.cs
index 0eecfd350d..1fc090597e 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectPackagesProjectNodeBuilderExtension.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectPackagesProjectNodeBuilderExtension.cs
@@ -72,7 +72,7 @@ namespace MonoDevelop.PackageManagement.NodeBuilders
void RefreshAllChildNodes ()
{
- DispatchService.GuiDispatch (() => {
+ Runtime.RunInMainThread (() => {
foreach (DotNetProject project in IdeApp.Workspace.GetAllItems<DotNetProject> ()) {
RefreshChildNodes (project);
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/BackgroundPackageActionRunner.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/BackgroundPackageActionRunner.cs
index 88ae83b30c..26cedc9004 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/BackgroundPackageActionRunner.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/BackgroundPackageActionRunner.cs
@@ -235,7 +235,7 @@ namespace MonoDevelop.PackageManagement
protected virtual void GuiDispatch (Action handler)
{
- DispatchService.GuiDispatch (handler);
+ Runtime.RunInMainThread (handler);
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopProjectSystem.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopProjectSystem.cs
index 7f22015029..99369c9c09 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopProjectSystem.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopProjectSystem.cs
@@ -55,7 +55,7 @@ namespace MonoDevelop.PackageManagement
new PackageManagementFileService (),
PackageManagementServices.ProjectService,
PackageManagementServices.PackageManagementEvents,
- DispatchService.GuiSyncDispatch,
+ DefaultGuiSyncDispatcher,
GuiSyncDispatchWithException)
{
}
@@ -473,11 +473,16 @@ namespace MonoDevelop.PackageManagement
static Task GuiSyncDispatchWithException (Func<Task> func)
{
- if (DispatchService.IsGuiThread)
+ if (Runtime.IsMainThread)
throw new InvalidOperationException ("GuiSyncDispatch called from GUI thread");
return Runtime.RunInMainThread (func);
}
+ internal static void DefaultGuiSyncDispatcher (MessageHandler action)
+ {
+ Runtime.RunInMainThread (() => action ()).Wait ();
+ }
+
void GuiSyncDispatch (Func<Task> func)
{
guiSyncDispatcherFunc (func).Wait ();
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageCompatibilityChecker.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageCompatibilityChecker.cs
index 12d9c9827d..f142f72935 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageCompatibilityChecker.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageCompatibilityChecker.cs
@@ -1,29 +1,29 @@
-//
-// PackageCompatibilityChecker.cs
-//
-// Author:
-// Matt Ward <matt.ward@xamarin.com>
-//
-// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
+//
+// PackageCompatibilityChecker.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
using System;
using System.Collections.Generic;
using System.IO;
@@ -32,7 +32,8 @@ using System.Runtime.Versioning;
using MonoDevelop.PackageManagement;
using MonoDevelop.Ide;
using NuGet;
-
+using MonoDevelop.Core;
+
namespace MonoDevelop.PackageManagement
{
public class PackageCompatibilityChecker
@@ -120,7 +121,7 @@ namespace MonoDevelop.PackageManagement
protected virtual void GuiDispatch (Action handler)
{
- DispatchService.GuiDispatch (handler);
+ Runtime.RunInMainThread (handler);
}
public void GenerateReport (TextWriter writer)
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEventsMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEventsMonitor.cs
index 95c2a22941..385cc5266b 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEventsMonitor.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEventsMonitor.cs
@@ -101,7 +101,7 @@ namespace MonoDevelop.PackageManagement
protected virtual void GuiSyncDispatch (MessageHandler handler)
{
- DispatchService.GuiSyncDispatch (handler);
+ Runtime.RunInMainThread (() => handler ()).Wait ();
}
void PackageOperationMessageLogged (object sender, PackageOperationMessageLoggedEventArgs e)
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementFileService.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementFileService.cs
index c935c4ef85..83a9ba4925 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementFileService.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementFileService.cs
@@ -71,9 +71,9 @@ namespace MonoDevelop.PackageManagement
public void OpenFile (string path)
{
- DispatchService.GuiSyncDispatch (() => {
+ Runtime.RunInMainThread (() => {
IdeApp.Workbench.OpenDocument (path, null, true);
- });
+ }).Wait ();
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProgressProvider.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProgressProvider.cs
index 9bd1d85ebe..4027a7b124 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProgressProvider.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProgressProvider.cs
@@ -1,34 +1,35 @@
-//
-// PackageManagementProgressProvider.cs
-//
-// Author:
-// Matt Ward <matt.ward@xamarin.com>
-//
-// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
+//
+// PackageManagementProgressProvider.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
using System;
using MonoDevelop.PackageManagement;
using NuGet;
using MonoDevelop.Ide;
-
+using MonoDevelop.Core;
+
namespace MonoDevelop.PackageManagement
{
public class PackageManagementProgressProvider : IProgressProvider
@@ -36,7 +37,7 @@ namespace MonoDevelop.PackageManagement
Action<Action> guiDispatcher;
public PackageManagementProgressProvider (IPackageRepositoryFactoryEvents repositoryFactoryEvents)
- : this (repositoryFactoryEvents, h => DispatchService.GuiDispatch (h))
+ : this (repositoryFactoryEvents, h => Runtime.RunInMainThread (h))
{
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProjectOperations.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProjectOperations.cs
index 49ccd1b854..ee2d961cd2 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProjectOperations.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProjectOperations.cs
@@ -1,29 +1,29 @@
-//
-// PackageManagementProjectOperations.cs
-//
-// Author:
-// Matt Ward <matt.ward@xamarin.com>
-//
-// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
+//
+// PackageManagementProjectOperations.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
using System;
using System.Collections.Generic;
using System.Linq;
@@ -31,7 +31,8 @@ using MonoDevelop.PackageManagement;
using MonoDevelop.Ide;
using MonoDevelop.Projects;
using NuGet;
-
+using MonoDevelop.Core;
+
namespace MonoDevelop.PackageManagement
{
public class PackageManagementProjectOperations : IPackageManagementProjectOperations
@@ -66,7 +67,7 @@ namespace MonoDevelop.PackageManagement
{
List<IPackageAction> actions = null;
- DispatchService.GuiSyncDispatch (() => {
+ Runtime.RunInMainThread (() => {
IPackageRepository repository = CreatePackageRepository (packageSourceUrl);
IPackageManagementProject packageManagementProject = solution.GetProject (repository, new DotNetProjectProxy ((DotNetProject)project));
actions = packages.Select (packageReference => {
@@ -75,7 +76,7 @@ namespace MonoDevelop.PackageManagement
action.PackageVersion = new SemanticVersion (packageReference.Version);
return (IPackageAction)action;
}).ToList ();
- });
+ }).Wait ();
ProgressMonitorStatusMessage progressMessage = GetProgressMonitorStatusMessages (actions);
backgroundActionRunner.RunAndWait (progressMessage, actions);
@@ -98,19 +99,15 @@ namespace MonoDevelop.PackageManagement
public IEnumerable<PackageManagementPackageReference> GetInstalledPackages (Project project)
{
- List<PackageManagementPackageReference> packageReferences = null;
-
- DispatchService.GuiSyncDispatch (() => {
+ return Runtime.RunInMainThread (() => {
string url = RegisteredPackageSources.DefaultPackageSourceUrl;
var repository = registeredPackageRepositories.CreateRepository (new PackageSource (url));
IPackageManagementProject packageManagementProject = solution.GetProject (repository, new DotNetProjectProxy ((DotNetProject)project));
- packageReferences = packageManagementProject
+ return packageManagementProject
.GetPackageReferences ()
.Select (packageReference => new PackageManagementPackageReference (packageReference.Id, packageReference.Version.ToString ()))
.ToList ();
- });
-
- return packageReferences;
+ }).Result;
}
void PackageUninstalled (object sender, ParentPackageOperationEventArgs e)
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRestoreRunner.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRestoreRunner.cs
index ef239bd110..b884bb563b 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRestoreRunner.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRestoreRunner.cs
@@ -139,7 +139,7 @@ namespace MonoDevelop.PackageManagement
/// </summary>
void RefreshProjectReferences (bool refreshMSBuildTargets)
{
- DispatchService.GuiDispatch (() => {
+ Runtime.RunInMainThread (() => {
foreach (IDotNetProject projectInSolution in solution.GetDotNetProjects ()) {
if (refreshMSBuildTargets) {
projectInSolution.RefreshProjectBuilder ();
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProgressMonitorExtensions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProgressMonitorExtensions.cs
index 6474b90952..9e7095dc14 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProgressMonitorExtensions.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProgressMonitorExtensions.cs
@@ -36,7 +36,7 @@ namespace MonoDevelop.PackageManagement
{
public static void ShowPackageConsole (this ProgressMonitor monitor)
{
- DispatchService.GuiDispatch (() => {
+ Runtime.RunInMainThread (() => {
var aggregatedMonitor = (PackageManagementProgressMonitor)monitor;
Pad pad = IdeApp.Workbench.ProgressMonitors.GetPadForMonitor (aggregatedMonitor.ConsoleMonitor);
if (pad != null) {
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ThreadSafePackageManagementEvents.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ThreadSafePackageManagementEvents.cs
index 9e79237e71..237d3ba750 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ThreadSafePackageManagementEvents.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ThreadSafePackageManagementEvents.cs
@@ -38,13 +38,11 @@ namespace MonoDevelop.PackageManagement
{
public class ThreadSafePackageManagementEvents : IThreadSafePackageManagementEvents
{
- static Action<MessageHandler> defaultGuiSyncDispatcher = DispatchService.GuiSyncDispatch;
-
Action<MessageHandler> guiSyncDispatcher;
IPackageManagementEvents unsafeEvents;
public ThreadSafePackageManagementEvents (IPackageManagementEvents unsafeEvents)
- : this (unsafeEvents, defaultGuiSyncDispatcher)
+ : this (unsafeEvents, MonoDevelopProjectSystem.DefaultGuiSyncDispatcher)
{
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackagesInSolution.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackagesInSolution.cs
index 19509840cf..bf24661425 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackagesInSolution.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackagesInSolution.cs
@@ -255,7 +255,7 @@ namespace MonoDevelop.PackageManagement
protected virtual void GuiDispatch (MessageHandler handler)
{
- DispatchService.GuiSyncDispatch (handler);
+ Runtime.RunInMainThread (() => handler ()).Wait ();
}
T GuiSyncDispatch<T> (Func<T> action)
diff --git a/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.Commands/WebReferenceCommandHandler.cs b/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.Commands/WebReferenceCommandHandler.cs
index 8877b2d292..6193f36310 100644
--- a/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.Commands/WebReferenceCommandHandler.cs
+++ b/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.Commands/WebReferenceCommandHandler.cs
@@ -8,6 +8,7 @@ using MonoDevelop.Ide.Gui.Components;
using MonoDevelop.Ide;
using System.Collections.Generic;
using MonoDevelop.Core.Assemblies;
+using System.Threading.Tasks;
namespace MonoDevelop.WebReferences.Commands
{
@@ -89,21 +90,21 @@ namespace MonoDevelop.WebReferences.Commands
UpdateReferenceContext = IdeApp.Workbench.StatusBar.CreateContext ();
UpdateReferenceContext.BeginProgress (GettextCatalog.GetPluralString ("Updating web reference", "Updating web references", items.Count));
- DispatchService.ThreadDispatch (() => {
+ Task.Run (() => {
for (int i = 0; i < items.Count; i ++) {
- DispatchService.GuiDispatch (() => UpdateReferenceContext.SetProgressFraction (Math.Max (0.1, (double)i / items.Count)));
+ Runtime.RunInMainThread (() => UpdateReferenceContext.SetProgressFraction (Math.Max (0.1, (double)i / items.Count)));
try {
items [i].Update();
} catch (Exception ex) {
- DispatchService.GuiSyncDispatch (() => {
+ Runtime.RunInMainThread (() => {
MessageService.ShowError (GettextCatalog.GetString ("Failed to update Web Reference '{0}'", items [i].Name), ex);
DisposeUpdateContext ();
- });
+ }).Wait ();
return;
}
}
- DispatchService.GuiDispatch (() => {
+ Runtime.RunInMainThread (() => {
// Make sure that we save all relevant projects, there should only be 1 though
foreach (var project in items.Select (i =>i.Project).Distinct ())
IdeApp.ProjectOperations.SaveAsync (project);
diff --git a/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences/WebReferencesService.cs b/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences/WebReferencesService.cs
index 00aa735380..d8b367469c 100644
--- a/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences/WebReferencesService.cs
+++ b/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences/WebReferencesService.cs
@@ -29,6 +29,7 @@ using MonoDevelop.Projects;
using System.Collections.Generic;
using MonoDevelop.WebReferences.WCF;
using MonoDevelop.WebReferences.WS;
+using MonoDevelop.Core;
namespace MonoDevelop.WebReferences
{
@@ -62,11 +63,11 @@ namespace MonoDevelop.WebReferences
// This is called from a background thread when webreferences are being
// updated asynchronously, so lets keep things simple for the users of
// this event and just ensure we proxy it to the main thread.
- if (MonoDevelop.Ide.DispatchService.IsGuiThread) {
+ if (Runtime.IsMainThread) {
if (WebReferencesChanged != null)
WebReferencesChanged (null, new WebReferencesChangedEventArgs (project));
} else {
- MonoDevelop.Ide.DispatchService.GuiDispatch (() => {
+ Runtime.RunInMainThread (() => {
if (WebReferencesChanged != null)
WebReferencesChanged (null, new WebReferencesChangedEventArgs (project));
});
diff --git a/main/src/addins/MonoDeveloperExtensions/Commands.cs b/main/src/addins/MonoDeveloperExtensions/Commands.cs
index 7c68a9da1a..9601cd5eb0 100644
--- a/main/src/addins/MonoDeveloperExtensions/Commands.cs
+++ b/main/src/addins/MonoDeveloperExtensions/Commands.cs
@@ -30,7 +30,7 @@ using MonoDevelop.Projects;
using MonoDevelop.Core;
using MonoDevelop.Components.Commands;
using MonoDevelop.Ide;
-
+using System.Threading.Tasks;
namespace MonoDeveloper
{
@@ -45,7 +45,7 @@ namespace MonoDeveloper
{
DotNetProject p = IdeApp.ProjectOperations.CurrentSelectedProject as DotNetProject;
if (p != null)
- DispatchService.BackgroundDispatch (new StatefulMessageHandler (Install), p);
+ Task.Run (() => Install (p));
}
protected override void Update (CommandInfo info)
diff --git a/main/src/addins/NUnit/Gui/TestResultsPad.cs b/main/src/addins/NUnit/Gui/TestResultsPad.cs
index 32bbd7716b..1908a3e83f 100644
--- a/main/src/addins/NUnit/Gui/TestResultsPad.cs
+++ b/main/src/addins/NUnit/Gui/TestResultsPad.cs
@@ -811,43 +811,43 @@ namespace MonoDevelop.NUnit
}
public void InitializeTestRun (UnitTest test)
{
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
pad.InitializeTestRun (test);
});
}
public void FinishTestRun ()
{
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
pad.FinishTestRun ();
});
}
public void Cancel ()
{
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
pad.Cancel ();
});
}
public void BeginTest (UnitTest test)
{
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
monitor.BeginTest (test);
});
}
public void EndTest (UnitTest test, UnitTestResult result)
{
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
monitor.EndTest (test, result);
});
}
public void ReportRuntimeError (string message, Exception exception)
{
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
monitor.ReportRuntimeError (message, exception);
});
}
public void WriteGlobalLog (string message)
{
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
monitor.WriteGlobalLog (message);
});
}
diff --git a/main/src/addins/NUnit/Services/NUnitAssemblyTestSuite.cs b/main/src/addins/NUnit/Services/NUnitAssemblyTestSuite.cs
index fd11cbfa3f..900d6090e6 100644
--- a/main/src/addins/NUnit/Services/NUnitAssemblyTestSuite.cs
+++ b/main/src/addins/NUnit/Services/NUnitAssemblyTestSuite.cs
@@ -206,7 +206,7 @@ namespace MonoDevelop.NUnit
ld.Path = AssemblyPath;
ld.TestInfoCachePath = cacheLoaded ? null : TestInfoCachePath;
ld.Callback = delegate {
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
AsyncCreateTests (ld);
});
};
diff --git a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs
index c77ae223e4..091402071e 100644
--- a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs
+++ b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs
@@ -36,6 +36,7 @@ using MonoDevelop.Ide.Editor.Extension;
using MonoDevelop.Ide.Editor;
using System.Threading.Tasks;
using System.Threading;
+using MonoDevelop.Core;
namespace MonoDevelop.TextTemplating.Gui
{
@@ -231,7 +232,7 @@ namespace MonoDevelop.TextTemplating.Gui
void RefillOutlineStore ()
{
- DispatchService.AssertGuiThread ();
+ Runtime.AssertMainThread ();
Gdk.Threads.Enter ();
refreshingOutline = false;
if (outlineTreeStore == null || !outlineTreeView.IsRealized)
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/Commands.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/Commands.cs
index 2866537935..8188e9e607 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/Commands.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/Commands.cs
@@ -163,7 +163,7 @@ namespace MonoDevelop.VersionControl.Git
msg = GettextCatalog.GetString ("No changes were available to stash");
}
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
IdeApp.Workbench.StatusBar.ShowMessage (msg);
});
}
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitCredentials.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitCredentials.cs
index c7351a8632..787d96bc0b 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitCredentials.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitCredentials.cs
@@ -128,14 +128,12 @@ namespace MonoDevelop.VersionControl.Git
state.KeyUsed++;
else {
SelectFileDialog dlg = null;
- bool success = false;
-
- DispatchService.GuiSyncDispatch (() => {
+ bool success = Runtime.RunInMainThread (() => {
dlg = new SelectFileDialog (GettextCatalog.GetString ("Select a private SSH key to use."));
dlg.ShowHidden = true;
dlg.CurrentFolder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
- success = dlg.Run ();
- });
+ return dlg.Run ();
+ }).Result;
if (!success || !File.Exists (dlg.SelectedFile + ".pub"))
throw new VersionControlException (GettextCatalog.GetString ("Invalid credentials were supplied. Aborting operation."));
@@ -147,10 +145,10 @@ namespace MonoDevelop.VersionControl.Git
};
if (KeyHasPassphrase (dlg.SelectedFile)) {
- DispatchService.GuiSyncDispatch (delegate {
+ result = Runtime.RunInMainThread (delegate {
using (var credDlg = new CredentialsDialog (url, types, cred))
- result = MessageService.ShowCustomDialog (credDlg) == (int)Gtk.ResponseType.Ok;
- });
+ return MessageService.ShowCustomDialog (credDlg) == (int)Gtk.ResponseType.Ok;
+ }).Result;
}
if (result)
@@ -169,10 +167,10 @@ namespace MonoDevelop.VersionControl.Git
return cred;
}
- DispatchService.GuiSyncDispatch (delegate {
+ result = Runtime.RunInMainThread (delegate {
using (var credDlg = new CredentialsDialog (url, types, cred))
- result = MessageService.ShowCustomDialog (credDlg) == (int)Gtk.ResponseType.Ok;
- });
+ return MessageService.ShowCustomDialog (credDlg) == (int)Gtk.ResponseType.Ok;
+ }).Result;
if (result) {
if ((types & SupportedCredentialTypes.UsernamePassword) != 0) {
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs
index 6047489ae6..57c430abcb 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs
@@ -806,7 +806,7 @@ namespace MonoDevelop.VersionControl.Git
static ConflictResult ResolveConflict (string file)
{
ConflictResult res = ConflictResult.Abort;
- DispatchService.GuiSyncDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
var dlg = new ConflictResolutionDialog ();
try {
dlg.Load (file);
@@ -828,7 +828,7 @@ namespace MonoDevelop.VersionControl.Git
dlg.Destroy ();
dlg.Dispose ();
}
- });
+ }).Wait ();
return res;
}
@@ -875,7 +875,7 @@ namespace MonoDevelop.VersionControl.Git
} catch {
string dlgName = null, dlgEmail = null;
- DispatchService.GuiSyncDispatch (() => {
+ Runtime.RunInMainThread (() => {
var dlg = new UserGitConfigDialog ();
try {
if ((Gtk.ResponseType)MessageService.RunCustomDialog (dlg) == Gtk.ResponseType.Ok) {
@@ -887,7 +887,7 @@ namespace MonoDevelop.VersionControl.Git
dlg.Destroy ();
dlg.Dispose ();
}
- });
+ }).Wait ();
name = dlgName;
email = dlgEmail;
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitService.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitService.cs
index a52ba0cc28..216603b88b 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitService.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitService.cs
@@ -165,13 +165,13 @@ namespace MonoDevelop.VersionControl.Git
{
if (status == StashApplyStatus.Conflicts) {
string msg = GettextCatalog.GetString ("Stash applied with conflicts");
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
IdeApp.Workbench.StatusBar.ShowWarning (msg);
});
}
else {
string msg = GettextCatalog.GetString ("Stash successfully applied");
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
IdeApp.Workbench.StatusBar.ShowMessage (msg);
});
}
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.Gui/WorkingCopyFormatDialog.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.Gui/WorkingCopyFormatDialog.cs
index 8fd15737fc..540252ad43 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.Gui/WorkingCopyFormatDialog.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.Gui/WorkingCopyFormatDialog.cs
@@ -61,12 +61,12 @@ namespace MonoDevelop.VersionControl.Subversion.Gui
action();
};
- if (DispatchService.IsGuiThread) {
+ if (Runtime.IsMainThread) {
// Already in GUI thread
del ();
}
else
- DispatchService.GuiDispatch (del);
+ Runtime.RunInMainThread (del);
}
}
}
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs
index cda778bab9..2109824438 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs
@@ -542,7 +542,7 @@ namespace MonoDevelop.VersionControl.Views
LoggingService.LogError ("Error retrieving history", ex);
}
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
ctx.Dispose ();
UpdateWidth ();
QueueDraw ();
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/StatusView.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/StatusView.cs
index 4c85bc0729..22090f22be 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/StatusView.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/StatusView.cs
@@ -472,7 +472,7 @@ namespace MonoDevelop.VersionControl.Views
}
List<VersionInfo> newList = new List<VersionInfo> ();
newList.AddRange (vc.GetDirectoryVersionInfo (filepath, remoteStatus, true));
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
if (!disposed)
LoadStatus (newList);
});
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/VersionControlDocumentInfo.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/VersionControlDocumentInfo.cs
index a002693010..885f6da247 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/VersionControlDocumentInfo.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/VersionControlDocumentInfo.cs
@@ -87,7 +87,7 @@ namespace MonoDevelop.VersionControl.Views
LoggingService.LogError ("Error retrieving history", ex);
}
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
OnUpdated (EventArgs.Empty);
});
mre.Set ();
@@ -110,7 +110,7 @@ namespace MonoDevelop.VersionControl.Views
mre.WaitOne ();
mre.Dispose ();
mre = null;
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
act ();
});
});
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/CheckoutCommand.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/CheckoutCommand.cs
index 3ce46d405f..6481e18997 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/CheckoutCommand.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/CheckoutCommand.cs
@@ -97,7 +97,7 @@ namespace MonoDevelop.VersionControl
}
if (projectFn != null) {
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
IdeApp.Workspace.OpenWorkspaceItem (projectFn);
});
}
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs
index e7a53efc8d..40be3e49a7 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs
@@ -380,7 +380,7 @@ namespace MonoDevelop.VersionControl
internal static void NotifyPrepareCommit (Repository repo, ChangeSet changeSet)
{
- if (!DispatchService.IsGuiThread) {
+ if (!Runtime.IsMainThread) {
Gtk.Application.Invoke (delegate {
NotifyPrepareCommit (repo, changeSet);
});
@@ -398,7 +398,7 @@ namespace MonoDevelop.VersionControl
internal static void NotifyBeforeCommit (Repository repo, ChangeSet changeSet)
{
- if (!DispatchService.IsGuiThread) {
+ if (!Runtime.IsMainThread) {
Gtk.Application.Invoke (delegate {
NotifyBeforeCommit (repo, changeSet);
});
@@ -416,7 +416,7 @@ namespace MonoDevelop.VersionControl
internal static void NotifyAfterCommit (Repository repo, ChangeSet changeSet, bool success)
{
- if (!DispatchService.IsGuiThread) {
+ if (!Runtime.IsMainThread) {
Gtk.Application.Invoke (delegate {
NotifyAfterCommit (repo, changeSet, success);
});
@@ -447,7 +447,7 @@ namespace MonoDevelop.VersionControl
public static void NotifyFileStatusChanged (FileUpdateEventArgs args)
{
- if (!DispatchService.IsGuiThread)
+ if (!Runtime.IsMainThread)
Gtk.Application.Invoke (delegate {
NotifyFileStatusChanged (args);
});
diff --git a/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/StatusBar.xaml.cs b/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/StatusBar.xaml.cs
index 263e492eef..dc1fabd45a 100644
--- a/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/StatusBar.xaml.cs
+++ b/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/StatusBar.xaml.cs
@@ -59,7 +59,7 @@ namespace WindowsPlatform.MainToolbar
wc++;
}
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
if (ec > 0) {
BuildResultPanelVisibility = Visibility.Visible;
BuildResultCount = ec;
diff --git a/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/WPFToolbar.cs b/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/WPFToolbar.cs
index d7872eeda6..28c13f831d 100644
--- a/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/WPFToolbar.cs
+++ b/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/WPFToolbar.cs
@@ -1,5 +1,6 @@
using MonoDevelop.Components.MainToolbar;
using MonoDevelop.Components.Windows;
+using MonoDevelop.Core;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -34,7 +35,7 @@ namespace WindowsPlatform.MainToolbar
if (newModel == null)
return;
- DispatchService.GuiDispatch(() => {
+ Runtime.RunInMainThread(() => {
ActiveConfiguration = newModel;
if (ConfigurationChanged != null)
@@ -48,7 +49,7 @@ namespace WindowsPlatform.MainToolbar
return;
using (var mutableModel = newModel.GetMutableModel()) {
- DispatchService.GuiDispatch(() => {
+ Runtime.RunInMainThread(() => {
ActiveRuntime = newModel;
var ea = new MonoDevelop.Components.MainToolbar.HandledEventArgs();
diff --git a/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsProxyCredentialProvider.cs b/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsProxyCredentialProvider.cs
index 598f796ce0..76970ec8c4 100644
--- a/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsProxyCredentialProvider.cs
+++ b/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsProxyCredentialProvider.cs
@@ -78,11 +78,11 @@ namespace MonoDevelop.Platform.Windows
{
NetworkCredential result = null;
- DispatchService.GuiSyncDispatch (() => {
+ Runtime.RunInMainThread (() => {
var form = new PlaceholderForm (credentialType, uri, null);
if (GdkWin32.RunModalWin32Form (form, IdeApp.Workbench.RootWindow))
result = new NetworkCredential (form.Username, form.Password, form.Domain);
- });
+ }).Wait ();
// store the obtained credentials in the auth store
// but don't store for the root url since it may have other credentials
diff --git a/main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs b/main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs
index 48f4bcb6fc..2204f06693 100644
--- a/main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs
+++ b/main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs
@@ -966,7 +966,7 @@ namespace MonoDevelop.Xml.Editor
void refillOutlineStore ()
{
- DispatchService.AssertGuiThread ();
+ Runtime.AssertMainThread ();
Gdk.Threads.Enter ();
refreshingOutline = false;
if (outlineTreeStore == null || !outlineTreeView.IsRealized)
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestSession.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestSession.cs
index a4fb16bb70..21ed5b9ef1 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestSession.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestSession.cs
@@ -108,7 +108,7 @@ namespace MonoDevelop.Components.AutoTest
object res = null;
Exception error = null;
- if (DispatchService.IsGuiThread) {
+ if (Runtime.IsMainThread) {
res = del ();
return safe ? SafeObject (res) : res;
}
@@ -182,7 +182,7 @@ namespace MonoDevelop.Components.AutoTest
public void TakeScreenshot (string screenshotPath)
{
#if MAC
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
try {
IntPtr handle = CGDisplayCreateImage (MainDisplayID ());
CoreGraphics.CGImage screenshot = ObjCRuntime.Runtime.GetINativeObject <CoreGraphics.CGImage> (handle, true);
@@ -325,7 +325,7 @@ namespace MonoDevelop.Components.AutoTest
public void ExecuteOnIdle (Action idleFunc, bool wait = true, int timeout = 20000)
{
- if (DispatchService.IsGuiThread) {
+ if (Runtime.IsMainThread) {
idleFunc ();
return;
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchResult.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchResult.cs
index 8a77c8cb47..bcca959283 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchResult.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchResult.cs
@@ -276,10 +276,9 @@ namespace MonoDevelop.Components.MainToolbar
if (CommandManager.ToCommandId (IdeApp.CommandService.GetActionCommand (command.Id)) == null) {
return false;
}
- DispatchService.GuiSyncDispatch (delegate {
-
+ Runtime.RunInMainThread (delegate {
ci = IdeApp.CommandService.GetCommandInfo (command.Id, new CommandTargetRoute (MainToolbar.LastCommandTarget));
- });
+ }).Wait ();
}
return ci.Enabled && ci.Visible;
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/StatusArea.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/StatusArea.cs
index a46b4a1092..d44c745af4 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/StatusArea.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/StatusArea.cs
@@ -397,7 +397,7 @@ namespace MonoDevelop.Components.MainToolbar
public StatusBarIcon ShowStatusIcon (Xwt.Drawing.Image pixbuf)
{
- DispatchService.AssertGuiThread ();
+ Runtime.AssertMainThread ();
StatusIcon icon = new StatusIcon (this, pixbuf);
statusIconBox.PackEnd (icon.box);
statusIconBox.ShowAll ();
@@ -657,7 +657,7 @@ namespace MonoDevelop.Components.MainToolbar
void ShowMessageInner (IconId image, string message, bool isMarkup)
{
- DispatchService.AssertGuiThread ();
+ Runtime.AssertMainThread ();
if (image == StockIcons.StatusError) {
// If the application doesn't have the focus, trigger the animation
@@ -814,7 +814,7 @@ namespace MonoDevelop.Components.MainToolbar
public void SetProgressFraction (double work)
{
- DispatchService.AssertGuiThread ();
+ Runtime.AssertMainThread ();
OnProgressFraction (new FractionEventArgs (work));
}
@@ -830,7 +830,7 @@ namespace MonoDevelop.Components.MainToolbar
public void Pulse ()
{
- DispatchService.AssertGuiThread ();
+ Runtime.AssertMainThread ();
OnProgressPulse (EventArgs.Empty);
}
@@ -838,7 +838,7 @@ namespace MonoDevelop.Components.MainToolbar
public bool AutoPulse {
get { return autoPulseTimeoutId != 0; }
set {
- DispatchService.AssertGuiThread ();
+ Runtime.AssertMainThread ();
if (value) {
if (autoPulseTimeoutId == 0) {
autoPulseTimeoutId = GLib.Timeout.Add (100, delegate {
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ToolsCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ToolsCommands.cs
index 99f634ff99..6f22f4170a 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ToolsCommands.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ToolsCommands.cs
@@ -32,6 +32,7 @@ using MonoDevelop.Core.Execution;
using MonoDevelop.Ide.Gui.Dialogs;
using System;
using MonoDevelop.Ide.Updater;
+using System.Threading.Tasks;
namespace MonoDevelop.Ide.Commands
{
@@ -84,7 +85,7 @@ namespace MonoDevelop.Ide.Commands
argumentsTool = StringParserService.Parse (customerArguments, IdeApp.Workbench.GetStringTagModel ());
}
- DispatchService.BackgroundDispatch (delegate {
+ Task.Run (delegate {
RunExternalTool (tool, argumentsTool);
});
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CustomTools/CustomToolService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CustomTools/CustomToolService.cs
index 941765a559..6847a6e3d8 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CustomTools/CustomToolService.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CustomTools/CustomToolService.cs
@@ -377,7 +377,7 @@ namespace MonoDevelop.Ide.CustomTools
}
if (result.Errors.Count > 0) {
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
foreach (CompilerError err in result.Errors)
TaskService.Errors.Add (new TaskListEntry (file.FilePath, err.ErrorText, err.Column, err.Line,
err.IsWarning? TaskSeverity.Warning : TaskSeverity.Error,
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution/ExecutionModeCommandService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution/ExecutionModeCommandService.cs
index 5e7a0c6ea6..269960bd81 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution/ExecutionModeCommandService.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution/ExecutionModeCommandService.cs
@@ -242,9 +242,8 @@ namespace MonoDevelop.Ide.Execution
internal static CustomExecutionMode ShowParamtersDialog (CommandExecutionContext ctx, IExecutionMode mode, CustomExecutionMode currentMode)
{
- CustomExecutionMode cmode = null;
-
- DispatchService.GuiSyncDispatch (delegate {
+ return Runtime.RunInMainThread (delegate {
+ CustomExecutionMode cmode = null;
CustomExecutionModeDialog dlg = new CustomExecutionModeDialog ();
try {
dlg.Initialize (ctx, mode, currentMode);
@@ -254,12 +253,12 @@ namespace MonoDevelop.Ide.Execution
if (dlg.Save)
SaveCustomCommand (ctx.Project, cmode);
}
+ return cmode;
} finally {
dlg.Destroy ();
dlg.Dispose ();
}
- });
- return cmode;
+ }).Result;
}
internal class CommandItem
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchProgressMonitor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchProgressMonitor.cs
index 363e263dc7..d7dcacd46d 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchProgressMonitor.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchProgressMonitor.cs
@@ -49,12 +49,12 @@ namespace MonoDevelop.Ide.FindInFiles
}
public PathMode PathMode {
- set { DispatchService.GuiDispatch (delegate { outputPad.PathMode = value; }); }
+ set { Runtime.RunInMainThread (delegate { outputPad.PathMode = value; }); }
}
public void ReportResult (SearchResult result)
{
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
try {
outputPad.ReportResult (result);
} catch (Exception ex) {
@@ -66,7 +66,7 @@ namespace MonoDevelop.Ide.FindInFiles
public void ReportResults (IEnumerable<SearchResult> results)
{
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
try {
outputPad.ReportResults (results);
} catch (Exception ex) {
@@ -77,7 +77,7 @@ namespace MonoDevelop.Ide.FindInFiles
public void ReportStatus (string resultMessage)
{
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
outputPad.ReportStatus (resultMessage);
});
}
@@ -85,7 +85,7 @@ namespace MonoDevelop.Ide.FindInFiles
protected override void OnWriteLog (string text)
{
if (outputPad == null) throw GetDisposedException ();
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
outputPad.WriteText (text);
});
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/MultiTaskProgressDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/MultiTaskProgressDialog.cs
index 453fa20070..f4669fe02d 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/MultiTaskProgressDialog.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/MultiTaskProgressDialog.cs
@@ -59,7 +59,7 @@ namespace MonoDevelop.Ide.Gui.Dialogs
public MultiTaskProgressDialog (bool allowCancel, bool showDetails, IDictionary<string, string> taskLabelAliases)
{
- DispatchService.AssertGuiThread ();
+ Runtime.AssertMainThread ();
this.Build();
this.allowCancel = allowCancel;
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/DefaultMonitorPad.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/DefaultMonitorPad.cs
index ca918fe06c..bc1a5848e5 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/DefaultMonitorPad.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/DefaultMonitorPad.cs
@@ -157,7 +157,7 @@ namespace MonoDevelop.Ide.Gui.Pads
logView.Clear ();
monitor = (LogViewProgressMonitor) logView.GetProgressMonitor ();
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
window.HasNewData = false;
window.HasErrors = false;
window.IsWorking = true;
@@ -173,7 +173,7 @@ namespace MonoDevelop.Ide.Gui.Pads
public void EndProgress ()
{
- DispatchService.GuiDispatch (delegate {
+ Runtime.RunInMainThread (delegate {
if (window != null) {
window.IsWorking = false;
if (monitor.Errors.Length > 0)
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/GtkSynchronizationContext.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/GtkSynchronizationContext.cs
deleted file mode 100644
index 45db9ce08e..0000000000
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/GtkSynchronizationContext.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// GtkSynchronizationContext.cs
-//
-// Author:
-// Lluis Sanchez Gual <lluis@novell.com>
-//
-// Copyright (c) 2011 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Threading;
-
-namespace MonoDevelop.Ide.Gui
-{
- public class GtkSynchronizationContext: SynchronizationContext
- {
- public override void Post (SendOrPostCallback d, object state)
- {
- DispatchService.GuiDispatch (delegate {
- d (state);
- });
- }
-
- public override void Send (SendOrPostCallback d, object state)
- {
- DispatchService.GuiSyncDispatch (delegate {
- d (state);
- });
- }
-
- public override SynchronizationContext CreateCopy ()
- {
- return new GtkSynchronizationContext ();
- }
- }
-}
-
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/GuiSyncContext.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/GuiSyncContext.cs
index 43ffea1bd4..e722f53062 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/GuiSyncContext.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/GuiSyncContext.cs
@@ -35,18 +35,18 @@ namespace MonoDevelop.Ide.Gui
{
public override void Dispatch (StatefulMessageHandler cb, object ob)
{
- if (DispatchService.IsGuiThread)
+ if (Runtime.IsMainThread)
cb (ob);
else
- DispatchService.GuiSyncDispatch (cb, ob);
+ Runtime.RunInMainThread (() => cb (ob)).Wait ();
}
public override void AsyncDispatch (StatefulMessageHandler cb, object ob)
{
- if (DispatchService.IsGuiThread)
+ if (Runtime.IsMainThread)
cb (ob);
else
- DispatchService.GuiDispatch (cb, ob);
+ Runtime.RunInMainThread (() => cb (ob));
}
}
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/MonoDevelopStatusBar.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/MonoDevelopStatusBar.cs
index 7f08acc146..f344b92a4e 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/MonoDevelopStatusBar.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/MonoDevelopStatusBar.cs
@@ -224,7 +224,7 @@ namespace MonoDevelop.Ide
public void ShowCaretState (int line, int column, int selectedChars, bool isInInsertMode)
{
- DispatchService.AssertGuiThread ();
+ Runtime.AssertMainThread ();
string cursorText = selectedChars > 0 ? String.Format ("{0,3} : {1,-3} - {2}", line, column, selectedChars) : String.Format ("{0,3} : {1,-3}", line, column);
if (cursorLabel.Text != cursorText)
cursorLabel.Text = cursorText;
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SyncContext.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SyncContext.cs
index 4491df322c..a7a0ec0838 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SyncContext.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SyncContext.cs
@@ -65,222 +65,5 @@ namespace MonoDevelop.Ide.Gui
{
cb.BeginInvoke (ob, null, null);
}
-
- public Delegate CreateSynchronizedDelegate (Delegate del)
- {
- lock (delegateFactories.SyncRoot)
- {
- Type delType = del.GetType();
- IDelegateFactory factory = delegateFactories [delType] as IDelegateFactory;
- if (factory == null)
- {
- Type t = GetDelegateFactoryType (delType);
- factory = Activator.CreateInstance (t) as IDelegateFactory;
- delegateFactories [delType] = factory;
- }
- return factory.Create (del, this);
- }
- }
-
- Type GetDelegateFactoryType (Type delegateType)
- {
- MethodInfo invoke = delegateType.GetMethod ("Invoke");
- ModuleBuilder module = GetModuleBuilder ();
-
- // *** Data class
- StringBuilder typeNameBuilder = new StringBuilder ();
- typeNameBuilder.Append ("__");
- typeNameBuilder.Append (delegateType.Name);
- Type[] generics = delegateType.GetGenericArguments ();
- if (generics != null) {
- foreach (Type t in generics) {
- typeNameBuilder.Append ("_");
- typeNameBuilder.Append (t.Name);
- }
- }
- TypeBuilder dataTypeBuilder = module.DefineType (typeNameBuilder + "_DelegateData_" + (typeCounter++), TypeAttributes.Public, typeof(object), Type.EmptyTypes);
-
- // Parameters
- ParameterInfo[] pars = invoke.GetParameters ();
- FieldBuilder[] paramFields = new FieldBuilder [pars.Length];
- Type[] paramTypes = new Type[pars.Length];
- for (int n=0; n<pars.Length; n++)
- {
- ParameterInfo pi = pars [n];
- paramFields [n] = dataTypeBuilder.DefineField ("p" + n, pi.ParameterType, FieldAttributes.Public);
- paramTypes [n] = pi.ParameterType;
- }
-
- // Return value
- FieldBuilder returnField = null;
- if (invoke.ReturnType != typeof(void))
- returnField = dataTypeBuilder.DefineField ("ret", invoke.ReturnType, FieldAttributes.Public);
-
- // Constructor
- ConstructorBuilder dataCtor = dataTypeBuilder.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
- ConstructorInfo baseCtor = typeof(object).GetConstructor (Type.EmptyTypes);
- ILGenerator gen = dataCtor.GetILGenerator();
- gen.Emit (OpCodes.Ldarg_0);
- gen.Emit (OpCodes.Call, baseCtor);
- gen.Emit (OpCodes.Ret);
-
-
- // *** Factory class
-
- TypeBuilder typeBuilder = module.DefineType (typeNameBuilder + "_DelegateFactory_" + typeCounter, TypeAttributes.Public, typeof(object), new Type[] {typeof(IDelegateFactory)});
-
- // Context and target delegate field
-
- FieldBuilder contextField = typeBuilder.DefineField ("context", typeof(SyncContext), FieldAttributes.Public);
- FieldBuilder targetField = typeBuilder.DefineField ("target", delegateType, FieldAttributes.Public);
-
- // Constructor
-
- ConstructorBuilder ctor = typeBuilder.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
- gen = ctor.GetILGenerator();
- gen.Emit (OpCodes.Ldarg_0);
- gen.Emit (OpCodes.Call, baseCtor);
- gen.Emit (OpCodes.Ret);
-
- // Dispatch method
-
- MethodBuilder methodDispatch = typeBuilder.DefineMethod ("Dispatch", MethodAttributes.Public, typeof(void), new Type[] {typeof(object)});
- gen = methodDispatch.GetILGenerator();
-
- LocalBuilder data = gen.DeclareLocal (dataTypeBuilder);
- gen.Emit (OpCodes.Ldarg_1);
- gen.Emit (OpCodes.Castclass, dataTypeBuilder);
- gen.Emit (OpCodes.Stloc, data);
-
- if (returnField != null)
- gen.Emit (OpCodes.Ldloc, data);
-
- gen.Emit (OpCodes.Ldarg_0);
- gen.Emit (OpCodes.Ldfld, targetField);
-
- for (int n=0; n<pars.Length; n++) {
- gen.Emit (OpCodes.Ldloc, data);
- gen.Emit (OpCodes.Ldfld, paramFields[n]);
- }
- gen.Emit (OpCodes.Callvirt, invoke);
-
- if (returnField != null)
- gen.Emit (OpCodes.Stfld, returnField);
-
- gen.Emit (OpCodes.Ret);
-
- // ProxyCall method
-
- MethodBuilder methodProxyCall = typeBuilder.DefineMethod ("ProxyCall", MethodAttributes.Public, invoke.ReturnType, paramTypes);
- gen = methodProxyCall.GetILGenerator();
-
- data = gen.DeclareLocal (dataTypeBuilder);
- gen.Emit (OpCodes.Newobj, dataCtor);
- gen.Emit (OpCodes.Stloc, data);
-
- for (int n=0; n<paramFields.Length; n++) {
- gen.Emit (OpCodes.Ldloc, data);
- gen.Emit (OpCodes.Ldarg, n+1);
- gen.Emit (OpCodes.Stfld, paramFields[n]);
- }
- gen.Emit (OpCodes.Ldarg_0);
- gen.Emit (OpCodes.Ldfld, contextField);
- gen.Emit (OpCodes.Ldarg_0);
- gen.Emit (OpCodes.Ldftn, methodDispatch);
- gen.Emit (OpCodes.Newobj, typeof(StatefulMessageHandler).GetConstructor (new Type[] {typeof(object), typeof(IntPtr)} ));
- gen.Emit (OpCodes.Ldloc, data);
-
- if (returnField != null) {
- gen.Emit (OpCodes.Callvirt, typeof(SyncContext).GetMethod ("Dispatch"));
- gen.Emit (OpCodes.Ldloc, data);
- gen.Emit (OpCodes.Ldfld, returnField);
- }
- else {
- gen.Emit (OpCodes.Callvirt, typeof(SyncContext).GetMethod ("AsyncDispatch"));
- }
- gen.Emit (OpCodes.Ret);
-
- // Create method
-
- MethodBuilder methodCreate = typeBuilder.DefineMethod ("Create", MethodAttributes.Public | MethodAttributes.Virtual, typeof(Delegate), new Type[] {typeof(Delegate), typeof(SyncContext)});
- gen = methodCreate.GetILGenerator();
- LocalBuilder vthis = gen.DeclareLocal (typeBuilder);
- gen.Emit (OpCodes.Newobj, ctor);
- gen.Emit (OpCodes.Stloc, vthis);
- gen.Emit (OpCodes.Ldloc, vthis);
- gen.Emit (OpCodes.Ldarg_1);
- gen.Emit (OpCodes.Castclass, delegateType);
- gen.Emit (OpCodes.Stfld, targetField);
- gen.Emit (OpCodes.Ldloc, vthis);
- gen.Emit (OpCodes.Ldarg_2);
- gen.Emit (OpCodes.Stfld, contextField);
- gen.Emit (OpCodes.Ldloc, vthis);
- gen.Emit (OpCodes.Ldftn, methodProxyCall);
- gen.Emit (OpCodes.Newobj, delegateType.GetConstructor (new Type[] {typeof(object), typeof(IntPtr)} ));
- gen.Emit (OpCodes.Ret);
- typeBuilder.DefineMethodOverride (methodCreate, typeof(IDelegateFactory).GetMethod ("Create"));
-
- dataTypeBuilder.CreateType ();
- return typeBuilder.CreateType ();
- }
-
- static ModuleBuilder GetModuleBuilder ()
- {
- if (module == null)
- {
- AppDomain myDomain = System.Threading.Thread.GetDomain();
- AssemblyName myAsmName = new AssemblyName();
- myAsmName.Name = "MonoDevelop.DelegateGenerator.GeneratedAssembly";
-
- asmBuilder = myDomain.DefineDynamicAssembly (myAsmName, AssemblyBuilderAccess.RunAndSave);
- module = asmBuilder.DefineDynamicModule ("MonoDevelop.DelegateGenerator.GeneratedAssembly", "MonoDevelop.DelegateGenerator.GeneratedAssembly.dll");
- }
- return module;
- }
- }
-
- public interface IDelegateFactory
- {
- Delegate Create (Delegate del, SyncContext ctx);
- }
-
-
- /* Sample class generated for the EventHandler delegate
-
- class __EventHandler_DelegateData
- {
- public object psender;
- public EventArgs pargs;
}
-
- class __EventHandler_DelegateFactory: IDelegateFactory
- {
- EventHandler target;
- SyncContext context;
-
- public Delegate Create (Delegate del, SyncContext ctx)
- {
- __EventHandler_DelegateFactory vthis = new __EventHandler_DelegateFactory ();
- vthis.target = del;
- vthis.context = ctx;
- return new EventHandler (vthis.ProxyCall);
- }
-
- public void ProxyCall (object sender, EventArgs args)
- {
- __EventHandler_DelegateData data = new __EventHandler_DelegateData ();
- data.psender = sender;
- data.pargs = args;
- StatefulMessageHandler msg = new StatefulMessageHandler (Dispatch);
- context.AsyncDispatch (msg, data);
- }
-
- public void Dispatch (object obj)
- {
- __EventHandler_DelegateData data = (__EventHandler_DelegateData) obj;
- target (data.psender, data.pargs);
- }
- }
-
- */
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.ProgressMonitoring/MessageDialogProgressMonitor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.ProgressMonitoring/MessageDialogProgressMonitor.cs
index bb8efc51e3..9c0d1bf7a5 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.ProgressMonitoring/MessageDialogProgressMonitor.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.ProgressMonitoring/MessageDialogProgressMonitor.cs
@@ -123,7 +123,7 @@ namespace MonoDevelop.Ide.ProgressMonitoring
protected override void OnCompleted ()
{
- DispatchService.GuiDispatch (ShowDialogs);
+ Runtime.RunInMainThread ((Action) ShowDialogs);
base.OnCompleted ();
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.ProgressMonitoring/MultiTaskDialogProgressMonitor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.ProgressMonitoring/MultiTaskDialogProgressMonitor.cs
index b5f3126d4e..79f23cb525 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.ProgressMonitoring/MultiTaskDialogProgressMonitor.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.ProgressMonitoring/MultiTaskDialogProgressMonitor.cs
@@ -162,7 +162,7 @@ namespace MonoDevelop.Ide.ProgressMonitoring
protected override void OnCompleted ()
{
- DispatchService.GuiDispatch (ShowDialogs);
+ Runtime.RunInMainThread ((Action) ShowDialogs);
base.OnCompleted ();
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj
index cb9249bd57..13102c7287 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj
@@ -2994,7 +2994,6 @@
<Compile Include="MonoDevelop.Ide.Gui.Dialogs\GtkErrorDialog.cs" />
<Compile Include="MonoDevelop.Ide.CodeFormatting\DefaultCodeFormatter.cs" />
<Compile Include="MonoDevelop.Ide.CodeFormatting\CodeFormatterExtensionNode.cs" />
- <Compile Include="MonoDevelop.Ide.Gui\GtkSynchronizationContext.cs" />
<Compile Include="MonoDevelop.Ide.Projects\NewPolicySetDialog.cs" />
<Compile Include="gtk-gui\MonoDevelop.Ide.Projects.NewPolicySetDialog.cs" />
<Compile Include="MonoDevelop.Components\HeaderBox.cs" />
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DispatchService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DispatchService.cs
index c27ffaba62..3cfc092921 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DispatchService.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DispatchService.cs
@@ -53,6 +53,28 @@ namespace MonoDevelop.Ide
static internal bool DispatchDebug;
const string errormsg = "An exception was thrown while dispatching a method call in the UI thread.";
+ class GtkSynchronizationContext: SynchronizationContext
+ {
+ public override void Post (SendOrPostCallback d, object state)
+ {
+ GuiDispatch (delegate {
+ d (state);
+ });
+ }
+
+ public override void Send (SendOrPostCallback d, object state)
+ {
+ GuiSyncDispatch (delegate {
+ d (state);
+ });
+ }
+
+ public override SynchronizationContext CreateCopy ()
+ {
+ return new GtkSynchronizationContext ();
+ }
+ }
+
internal static void Initialize ()
{
if (guiContext != null)
@@ -71,32 +93,13 @@ namespace MonoDevelop.Ide
thrBackground.Start ();
DispatchDebug = Environment.GetEnvironmentVariable ("MONODEVELOP_DISPATCH_DEBUG") != null;
- }
-
- public static Task<T> GuiDispatch<T> (Func<T> cb)
- {
- TaskCompletionSource<T> ts = new TaskCompletionSource<T> ();
- if (IsGuiThread) {
- try {
- ts.SetResult (cb ());
- } catch (Exception ex) {
- ts.SetException (ex);
- }
- return ts.Task;
- }
-
- QueueMessage (new GenericMessageContainer (() => {
- try {
- ts.SetResult (cb ());
- } catch (Exception ex) {
- ts.SetException (ex);
- }
- }, false));
- return ts.Task;
+ SynchronizationContext = new GtkSynchronizationContext ();
}
- public static Task GuiDispatch (Action cb)
+ public static SynchronizationContext SynchronizationContext { get; private set; }
+
+ static Task GuiDispatch (Action cb)
{
TaskCompletionSource<bool> ts = new TaskCompletionSource<bool> ();
if (IsGuiThread) {
@@ -120,17 +123,7 @@ namespace MonoDevelop.Ide
return ts.Task;
}
- internal static void GuiDispatch (StatefulMessageHandler cb, object state)
- {
- if (IsGuiThread) {
- cb (state);
- return;
- }
-
- QueueMessage (new StatefulMessageContainer (cb, state, false));
- }
-
- public static void GuiSyncDispatch (MessageHandler cb)
+ static void GuiSyncDispatch (MessageHandler cb)
{
if (IsGuiThread) {
cb ();
@@ -146,22 +139,6 @@ namespace MonoDevelop.Ide
throw new Exception (errormsg, mc.Exception);
}
- public static void GuiSyncDispatch (StatefulMessageHandler cb, object state)
- {
- if (IsGuiThread) {
- cb (state);
- return;
- }
-
- StatefulMessageContainer mc = new StatefulMessageContainer (cb, state, true);
- lock (mc) {
- QueueMessage (mc);
- Monitor.Wait (mc);
- }
- if (mc.Exception != null)
- throw new Exception (errormsg, mc.Exception);
- }
-
static DateTime lastPendingEvents;
public static void RunPendingEvents ()
{
@@ -203,30 +180,17 @@ namespace MonoDevelop.Ide
}
}
- public static bool IsGuiThread
+ static bool IsGuiThread
{
get { return guiThread == Thread.CurrentThread; }
}
- public static void AssertGuiThread ()
+ static void AssertGuiThread ()
{
if (guiThread != Thread.CurrentThread)
throw new InvalidOperationException ("This method can only be called in the GUI thread");
}
- public static Delegate GuiDispatchDelegate (Delegate del)
- {
- return guiContext.CreateSynchronizedDelegate (del);
- }
-
- public static T GuiDispatchDelegate<T> (T theDelegate)
- {
- if (guiContext == null)
- return theDelegate;
- Delegate del = (Delegate)(object)theDelegate;
- return (T)(object)guiContext.CreateSynchronizedDelegate (del);
- }
-
/// <summary>
/// Runs the provided delegate in the background, but waits until finished, pumping the
/// message queue if necessary.
@@ -262,7 +226,7 @@ namespace MonoDevelop.Ide
QueueBackground (new GenericMessageContainer (cb, false));
}
- public static void BackgroundDispatch (StatefulMessageHandler cb, object state)
+ static void BackgroundDispatch (StatefulMessageHandler cb, object state)
{
QueueBackground (new StatefulMessageContainer (cb, state, false));
}
@@ -276,24 +240,6 @@ namespace MonoDevelop.Ide
}
}
- public static void ThreadDispatch (MessageHandler cb)
- {
- GenericMessageContainer smc = new GenericMessageContainer (cb, false);
- Thread t = new Thread (new ThreadStart (smc.Run));
- t.Name = "Message dispatcher";
- t.IsBackground = true;
- t.Start ();
- }
-
- public static void ThreadDispatch (StatefulMessageHandler cb, object state)
- {
- StatefulMessageContainer smc = new StatefulMessageContainer (cb, state, false);
- Thread t = new Thread (new ThreadStart (smc.Run));
- t.Name = "Message dispatcher";
- t.IsBackground = true;
- t.Start ();
- }
-
static bool guiDispatcher ()
{
GenericMessageContainer msg;
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs
index 1e83b18645..8ec40edab7 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs
@@ -133,7 +133,7 @@ namespace MonoDevelop.Ide
DispatchService.Initialize ();
// Set a synchronization context for the main gtk thread
- SynchronizationContext.SetSynchronizationContext (new GtkSynchronizationContext ());
+ SynchronizationContext.SetSynchronizationContext (DispatchService.SynchronizationContext);
Runtime.MainSynchronizationContext = SynchronizationContext.Current;
AddinManager.AddinLoadError += OnAddinError;
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/MessageService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/MessageService.cs
index 9fdfba7018..2854718e17 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/MessageService.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/MessageService.cs
@@ -368,14 +368,14 @@ namespace MonoDevelop.Ide
dialog.Title = BrandingService.ApplicationName;
#if MAC
- DispatchService.GuiSyncDispatch (() => {
+ Runtime.RunInMainThread (() => {
// If there is a native NSWindow model window running, we need
// to show the new dialog over that window.
if (NSApplication.SharedApplication.ModalWindow != null)
dialog.Shown += HandleShown;
else
PlaceDialog (dialog, parent);
- });
+ }).Wait ();
#endif
return GtkWorkarounds.RunDialogWithNotification (dialog);
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs
index 574979ff78..c8f952933e 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs
@@ -905,7 +905,7 @@ namespace MonoDevelop.Ide
} catch (Exception ex) {
LoggingService.LogError ("Could not load parser database.", ex);
}
- if (DispatchService.IsGuiThread)
+ if (Runtime.IsMainThread)
NotifyItemAddedGui (item, IsReloading);
else {
bool reloading = IsReloading;
@@ -939,7 +939,7 @@ namespace MonoDevelop.Ide
internal void NotifyItemRemoved (WorkspaceItem item)
{
- if (DispatchService.IsGuiThread)
+ if (Runtime.IsMainThread)
NotifyItemRemovedGui (item, IsReloading);
else {
bool reloading = IsReloading;