diff --git a/src/MessageBus/DSoft.Messaging/DSoft.Messaging.csproj b/src/MessageBus/DSoft.Messaging/DSoft.Messaging.csproj index a2f123c..9e08071 100644 --- a/src/MessageBus/DSoft.Messaging/DSoft.Messaging.csproj +++ b/src/MessageBus/DSoft.Messaging/DSoft.Messaging.csproj @@ -11,8 +11,6 @@ Profile158 v4.0 1.3 - 8.0.30703 - 2.0 true diff --git a/src/MessageBus/DSoft.Messaging/MessageBus.cs b/src/MessageBus/DSoft.Messaging/MessageBus.cs index a1b8d43..fcca8d0 100644 --- a/src/MessageBus/DSoft.Messaging/MessageBus.cs +++ b/src/MessageBus/DSoft.Messaging/MessageBus.cs @@ -24,8 +24,6 @@ public class MessageBus public MessageBus() { - var aSyncContext = TaskScheduler.FromCurrentSynchronizationContext(); - } #endregion @@ -69,10 +67,10 @@ internal MessageBusEventHandlerCollection EventHandlers { } /// - /// Gets or sets the sync context. + /// Gets or sets the sync context for the UI thread. /// /// The sync context. - private TaskScheduler SyncContext + public TaskScheduler SyncContext { get; set; @@ -166,11 +164,7 @@ public void DeRegister (Action Action) where T : Mess private void Execute (Action Action, object Sender, MessageBusEvent Evnt) { - Task.Factory.StartNew (() => { - Action (Sender, Evnt); - }, - CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default); - + Action(Sender, Evnt); } /// @@ -287,9 +281,10 @@ public static void PostEvent (String EventId, object Sender, object[] Data) /// Command. public void RunOnUiThread(Action Command) { - var cul = Thread.CurrentThread; + if (SyncContext == null) + throw new ArgumentNullException ("SyncContext"); - //update the UI + //update the UI Task.Factory.StartNew(() => { if (Command != null)