Commit 33fca118 authored by Marc Gravell's avatar Marc Gravell

Merge pull request #160 from turowicz/master

provide a way of overriding the task factory which se.redis will use #159
parents cd044317 eff8123e
......@@ -51,6 +51,30 @@ public static ConfiguredTaskAwaitable<T> ForAwait<T>(this Task<T> task)
/// </summary>
public sealed partial class ConnectionMultiplexer : IDisposable
{
private static TaskFactory _factory = null;
/// <summary>
/// Provides a way of overriding the default Task Factory. If not set, it will use the default Task.Factory.
/// Useful when top level code sets it's own factory which may interfere with Redis queries.
/// </summary>
public static TaskFactory Factory
{
get
{
if (_factory != null)
{
return _factory;
}
return Task.Factory;
}
set
{
_factory = value;
}
}
/// <summary>
/// Get summary statistics associates with this server
/// </summary>
......@@ -738,7 +762,7 @@ private static ConnectionMultiplexer ConnectImpl(Func<ConnectionMultiplexer> mul
killMe = muxer;
// note that task has timeouts internally, so it might take *just over* the regular timeout
// wrap into task to force async execution
var task = Task.Factory.StartNew(() => { return muxer.ReconfigureAsync(true, false, log, null, "connect").Result; });
var task = Factory.StartNew(() => { return muxer.ReconfigureAsync(true, false, log, null, "connect").Result; });
if (!task.Wait(muxer.SyncConnectTimeout(true)))
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment