You need to provide a SynchronizationContext. This is how I handle it:
[SetUp]
public void TestSetUp()
{
SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
}
More Related Contents:
- What is the difference between task and thread?
- What is the difference between Task.Run() and Task.Factory.StartNew()
- When to use Task.Delay, when to use Thread.Sleep?
- Execute task in background in WPF application
- Does the use of async/await create a new thread?
- When to use BlockingCollection and when ConcurrentBag instead of List?
- Is it considered acceptable to not call Dispose() on a TPL Task object?
- Starting Tasks In foreach Loop Uses Value of Last Item [duplicate]
- Multiple Parallel.ForEach loops in .Net
- Proper way to implement a never ending task. (Timers vs Task)
- How to create a task (TPL) running a STA thread?
- How to put a task to sleep (or delay) in C# 4.0?
- Is Task.Factory.StartNew() guaranteed to use another thread than the calling thread?
- Cancelling a pending task synchronously on the UI thread
- Does using Tasks (TPL) library make an application multithreaded?
- ConfigureAwait pushes the continuation to a pool thread
- ThreadPool.QueueUserWorkItem vs Task.Factory.StartNew
- Process queue with multithreading or tasks
- How to achieve remove_if functionality in .NET ConcurrentDictionary
- Calling async methods from non-async code
- SynchronizationLockException on Monitor.Exit when using await
- Why CancellationToken is separate from CancellationTokenSource?
- Need to understand the usage of SemaphoreSlim
- Should i use ThreadPools or Task Parallel Library for IO-bound operations
- Faulted vs Canceled task status after CancellationToken.ThrowIfCancellationRequested
- Synchronous implementation of interface that returns Task
- The lack of non-capturing Task.Yield forces me to use Task.Run, why follow that?
- How to properly parallelise job heavily relying on I/O
- Why does this Parallel.ForEach code freeze the program up?
- Wrapping ManualResetEvent as awaitable task