Browse Source

Register SyncContext in RegisterServices

pull/95/head
Nikita Tsukanov 11 years ago
parent
commit
7d416715fe
  1. 3
      src/Perspex.Application/Application.cs
  2. 3
      src/Perspex.Base/PerspexObject.cs
  3. 8
      src/Perspex.Base/Threading/PerspexSynchronizationContext.cs

3
src/Perspex.Application/Application.cs

@ -55,7 +55,7 @@ namespace Perspex
{
throw new InvalidOperationException("Cannot create more than one Application instance.");
}
PerspexSynchronizationContext.InstallIfNeeded();
Current = this;
}
@ -150,6 +150,7 @@ namespace Perspex
/// </summary>
protected virtual void RegisterServices()
{
PerspexSynchronizationContext.InstallIfNeeded();
this.FocusManager = new FocusManager();
this.InputManager = new InputManager();

3
src/Perspex.Base/PerspexObject.cs

@ -4,8 +4,6 @@
// </copyright>
// -----------------------------------------------------------------------
using Perspex.Threading;
namespace Perspex
{
using System;
@ -102,7 +100,6 @@ namespace Perspex
/// </summary>
public PerspexObject()
{
PerspexSynchronizationContext.InstallIfNeeded();
this.propertyLog = Log.ForContext(new[]
{
new PropertyEnricher("Area", "Property"),

8
src/Perspex.Base/Threading/PerspexSynchronizationContext.cs

@ -1,12 +1,12 @@
using System.Threading;
namespace Perspex.Threading
namespace Perspex.Threading
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
/// <summary>
/// SynchronizationContext to be used on main thread
@ -14,7 +14,7 @@ namespace Perspex.Threading
public class PerspexSynchronizationContext : SynchronizationContext
{
/// <summary>
/// Controls if SynchronizationContext should be installed in InstallIfNeeded
/// Controls if SynchronizationContext should be installed in InstallIfNeeded. Used by Designer.
/// </summary>
public static bool AutoInstall { get; set; } = true;

Loading…
Cancel
Save