本文整理汇总了C#中TaskScheduler类的典型用法代码示例。如果您正苦于以下问题:C# TaskScheduler类的具体用法?C# TaskScheduler怎么用?C# TaskScheduler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TaskScheduler类属于命名空间,在下文中一共展示了TaskScheduler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DiffViewer
public DiffViewer(TaskScheduler scheduler, HeapRecording instance)
: base(scheduler)
{
InitializeComponent();
ListFormat = new StringFormat {
Trimming = StringTrimming.None,
FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.FitBlackBox
};
Timeline.ItemValueGetter = GetBytesTotal;
Timeline.ItemValueFormatter = MainWindow.FormatSizeBytes;
Instance = instance;
if (Instance != null) {
Timeline.Items = Instance.Snapshots;
Instance.TracebacksFiltered += Instance_TracebacksFiltered;
ViewHistogramByModuleMenu.Enabled = ViewHistogramByFunctionMenu.Enabled = true;
ViewHistogramBySourceFolderMenu.Enabled = ViewHistogramBySourceFileMenu.Enabled = true;
ViewHistogramByNamespaceMenu.Enabled = ViewTreemapMenu.Enabled = true;
} else {
Timeline.Visible = false;
MainSplit.Height += Timeline.Bottom - MainSplit.Bottom;
ViewHistogramByModuleMenu.Enabled = ViewHistogramByFunctionMenu.Enabled = false;
ViewHistogramBySourceFolderMenu.Enabled = ViewHistogramBySourceFileMenu.Enabled = false;
ViewHistogramByNamespaceMenu.Enabled = ViewTreemapMenu.Enabled = false;
}
}
示例2: SetUp
public virtual void SetUp()
{
Scheduler = new TaskScheduler();
TestFile = Path.GetTempFileName();
Storage = new AlternateStreamSource(TestFile);
}
示例3: TaskScheduler
public void TaskScheduler_Shutdownで登録済みのタスクの終了待ちできる()
{
var scheduler = new TaskScheduler();
var skipScheduler = new TaskScheduler();
List<Task> tasks = new List<Task>();
for (int i = 0; i < 100; i++)
{
var t = Util.RandomTask(scheduler, skipScheduler);
tasks.Add(t);
scheduler.Update();
skipScheduler.Update();
}
// RandomTask と WaitShutdown の実装上、5秒も待てば終わるはず
var s = scheduler.BeginShutdown(TimeSpan.FromSeconds(10));
while (true)
{
if (s.IsFaulted || s.IsCompleted || s.IsCanceled) break;
for (int i = 0; i < 50; i++) scheduler.Update();
for (int i = 0; i < 5; i++) skipScheduler.Update();
System.Threading.Thread.Sleep(1);
}
Assert.AreEqual(TaskSchedulerStatus.ShutdownCompleted, scheduler.Status);
foreach (var t in tasks)
{
Assert.AreEqual(TaskStatus.RanToCompletion, t.Status);
}
}
示例4: TestClonePipelining
public void TestClonePipelining()
{
DoQuery("DROP TABLE IF EXISTS Test");
DoQuery("CREATE TABLE Test (value int)");
for (int i = 0; i < 10; i++)
DoQuery(String.Format("INSERT INTO Test (value) VALUES ({0})", i));
using (var scheduler = new TaskScheduler())
using (var qm = new ConnectionWrapper(scheduler, Connection)) {
var q = qm.BuildQuery("SELECT * FROM Test");
var iter = q.Execute();
var iterF = scheduler.Start(iter.Fetch());
var fClone = qm.Clone();
Assert.IsFalse(fClone.Completed);
iter.Dispose();
iterF.Dispose();
scheduler.WaitFor(fClone);
using (var dupe = fClone.Result) {
q = dupe.BuildQuery("SELECT COUNT(value) FROM Test WHERE value = ?");
var f = q.ExecuteScalar(5);
var result = scheduler.WaitFor(f);
Assert.AreEqual(result, 1);
}
}
}
示例5: QueueStep
void ISchedulable.Schedule(TaskScheduler scheduler, IFuture future)
{
_Future = future;
_Scheduler = scheduler;
_Future.RegisterOnDispose(this.OnDisposed);
QueueStep();
}
示例6: InsertBenchmark
public void InsertBenchmark (int warmupLength, int numInsertions, Func<IJobQueue> jobQueueFactory, Func<ConnectionWrapper, Query, int, IEnumerator<object>> insertTask) {
DoQuery("CREATE TABLE Test (A INTEGER NOT NULL, B INTEGER NOT NULL)");
var jobQueue = jobQueueFactory();
var wjq = jobQueue as WindowsMessageJobQueue;
using (var scheduler = new TaskScheduler(() => jobQueue))
using (var cw = new ConnectionWrapper(scheduler, Connection))
using (var query = cw.BuildQuery("INSERT INTO Test (A, B) VALUES (?, ?)")) {
scheduler.WaitFor(insertTask(cw, query, warmupLength));
DoQuery("DELETE FROM Test");
var e = insertTask(cw, query, numInsertions);
long timeStart = Time.Ticks;
scheduler.WaitFor(e);
long elapsed = Time.Ticks - timeStart;
var elapsedSeconds = (decimal)elapsed / Time.SecondInTicks;
Console.WriteLine(
"Inserted {0} row(s) in {1:00.000} second(s) at ~{2:000000.00} rows/sec.",
numInsertions, elapsedSeconds, numInsertions / elapsedSeconds
);
}
}
示例7: LogWindow
public LogWindow(TaskScheduler scheduler)
: base(scheduler)
{
InitializeComponent();
GC.Collect();
}
示例8: RunSettingTaskDetail
public RunSettingTaskDetail(TaskScheduler task)
{
InitializeComponent();
this.LayoutRoot.DataContext = task;
this.ContentTextBox.Text = this.GetParameterSettings(task);
}
示例9: Registration
public Registration () {
Scope = CancellationScope.Current;
Scheduler = TaskScheduler.Current;
if (Scheduler == null)
throw new InvalidOperationException("No implicitly active TaskScheduler on this thread.");
}
示例10: TaskScheduler
public void タスクの2重起動防止()
{
const int Frame = 30;
const int N = 10;
var scheduler = new TaskScheduler();
Func<Task> starter = () => Util.DelayFrame(Frame, scheduler);
var distinct = TaskUtility.Distinct(starter);
Task task = distinct();
for (int i = 0; i < (Frame + 1) * N; i++)
{
var t = distinct();
if (task.IsCompleted)
{
// タスク完了してたら次のタスクを起動してるはず。
Assert.IsFalse(object.ReferenceEquals(task, t));
task = t;
}
else
{
// タスク完了するまでは同じタスクが何度も帰ってくるはず。
Assert.IsTrue(object.ReferenceEquals(task, t));
}
scheduler.Update();
}
}
示例11: MyForm
public MyForm() {
// Get a reference to a synchronization context task scheduler
m_syncContextTaskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
Text = "Synchronization Context Task Scheduler Demo";
Visible = true; Width = 600; Height = 100;
}
示例12: ProcessWatcher
public ProcessWatcher(TaskScheduler scheduler, params string[] processNames)
{
Scheduler = scheduler;
foreach (var pname in processNames) {
var invariant = Path.GetFileNameWithoutExtension(pname).ToLowerInvariant();
ProcessNames.Add(invariant);
foreach (var process in Process.GetProcessesByName(invariant)) {
RunningProcessIds.Add(process.Id);
NewProcesses.Enqueue(process);
}
}
try {
var query = new WqlEventQuery(@"SELECT * FROM Win32_ProcessStartTrace");
Watcher = new ManagementEventWatcher(query);
Watcher.Options.BlockSize = 1;
Watcher.EventArrived += new EventArrivedEventHandler(OnEventArrived);
Watcher.Start();
WatcherEnabled = true;
} catch {
Watcher = null;
WatcherEnabled = false;
TimerTask = Scheduler.Start(InitTimer(), TaskExecutionPolicy.RunAsBackgroundTask);
}
}
示例13: HttpServer
public HttpServer(TaskScheduler scheduler)
{
EndPoints = new EndPointList(this);
Scheduler = scheduler;
RequestOnComplete = _RequestOnComplete;
}
示例14: frmSchedule
public frmSchedule(DataStorage data, TaskScheduler.ScheduledTasks tasks, DataStorage.JobRow job, bool newJob)
{
Localization.ChangeLanguage();
InitializeComponent();
m_Data = data;
m_NewJob = newJob;
m_Job = job;
m_Tasks = tasks;
}
示例15: SchedulerProvider
public SchedulerProvider()
{
Task = new TaskScheduler();
IOCompletion = new IOCompletionScheduler();
Current = new CurrentScheduler();
Immediate = new ImmediateScheduler();
NewThread = new NewThreadScheduler();
ThreadPool = new ThreadPoolScheduler();
}