本文整理汇总了C#中IScheduler.Post方法的典型用法代码示例。如果您正苦于以下问题:C# IScheduler.Post方法的具体用法?C# IScheduler.Post怎么用?C# IScheduler.Post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScheduler
的用法示例。
在下文中一共展示了IScheduler.Post方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
public void Start()
{
m_Scheduler = KayakScheduler.Factory.Create(new SchedulerDelegate());
m_Server = KayakServer.Factory.CreateHttp(new NancyRequestDelegate(m_Engine), m_Scheduler);
IDisposable disposable = m_Server.Listen(m_EndPoint);
Thread schedulerWorkerThread = new Thread(SchedulerWorker);
schedulerWorkerThread.IsBackground = true;
schedulerWorkerThread.Start(disposable);
m_Scheduler.Post(GetLocalPort);
}
示例2: RescheduleBody
static BodyDelegate RescheduleBody(IScheduler theScheduler, BodyDelegate body)
{
// flush and end are tranported on theScheduler.
// write is not, because you want the return value to be
// false when the data is not buffering.
return (write, flush, end, cancel) =>
theScheduler.Post(() =>
body(
write,
drained =>
{
theScheduler.Post(() =>
{
if (!flush(() => if (drained != null) theScheduler.Post(drained)))
if (drained != null) drained.Invoke();
});
示例3: SetUp
public void SetUp()
{
ep = new IPEndPoint(IPAddress.Loopback, Config.Port);
wh = new ManualResetEventSlim();
schedulerDelegate = new SchedulerDelegate();
scheduler = new DefaultKayakScheduler(schedulerDelegate);
schedulerDelegate.OnStoppedAction = () =>
{
stopListening.Dispose();
stopListening = null;
wh.Set();
};
schedulerDelegate.OnExceptionAction = e =>
{
schedulerError = e;
Debug.WriteLine("Error on scheduler");
e.DebugStackTrace();
scheduler.Stop();
};
scheduler.Post(() =>
{
stopListening = server.Listen(ep);
schedulerStartedAction();
});
serverDelegate = new ServerDelegate();
server = new DefaultKayakServer(serverDelegate, scheduler);
clientSocketDelegate = new SocketDelegate();
client = new DefaultKayakSocket(clientSocketDelegate, scheduler);
}
示例4: RescheduleBody
static BodyDelegate RescheduleBody(IScheduler theScheduler, BodyDelegate body)
{
// flush and end are tranported on theScheduler.
// write is not, because you want the return value to be
// false when the data is not buffering.
return (write, end, cancel) =>
theScheduler.Post(() =>
body(
(data, callback) =>
{
if (callback == null)
{
return write(data, callback);
}
theScheduler.Post(() =>
{
if (!write(data, () => { theScheduler.Post(callback); }))
callback.Invoke();
});
return true;
},
ex => theScheduler.Post(() => end(ex)),
cancel));
}
示例5: RunApplication
public void RunApplication(int port, Action<FubuRuntime> activation)
{
_port = port;
_listeningEndpoint = new IPEndPoint(IPAddress.Any, _port);
Console.WriteLine("Listening on " + _listeningEndpoint);
_applicationDelegate = AppBuilder.BuildConfiguration(x => x.RescheduleCallbacks().Run(ExecuteRequest));
_scheduler = KayakScheduler.Factory.Create(_schedulerDelegate);
_server = KayakServer.Factory.CreateGate(_applicationDelegate, _scheduler, null);
if (_listeningEndpoint == null)
{
throw new InvalidOperationException("Start() can only be called after RunApplication() and Stop()");
}
var runtime = rebuildFubuMVCApplication();
_kayakListenerDisposer = _server.Listen(_listeningEndpoint);
_scheduler.Post(() => ThreadPool.QueueUserWorkItem(o => activation(runtime)));
_scheduler.Start();
}
示例6: SetUp
public void SetUp()
{
ep = new IPEndPoint(IPAddress.Loopback, Config.Port);
wh = new ManualResetEventSlim();
IDisposable d = null;
var schedulerDelegate = new SchedulerDelegate();
schedulerDelegate.OnStoppedAction = () =>
{
d.Dispose();
wh.Set();
};
scheduler = new KayakScheduler(schedulerDelegate);
scheduler.Post(() =>
{
d = server.Listen(ep);
schedulerStartedAction();
});
var serverDelegate = new ServerDelegate();
server = new KayakServer(serverDelegate, scheduler);
clientSocketDelegate = new SocketDelegate();
client = new KayakSocket(clientSocketDelegate, scheduler);
}