当前位置: 首页>>代码示例>>C#>>正文


C# TaskScheduler类代码示例

本文整理汇总了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;
            }
        }
开发者ID:kg,项目名称:HeapProfiler,代码行数:28,代码来源:DiffViewer.cs

示例2: SetUp

        public virtual void SetUp()
        {
            Scheduler = new TaskScheduler();

            TestFile = Path.GetTempFileName();
            Storage = new AlternateStreamSource(TestFile);
        }
开发者ID:sq,项目名称:DataMangler,代码行数:7,代码来源:BasicTests.cs

示例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);
            }
        }
开发者ID:endo0407,项目名称:IteratorTasks,代码行数:32,代码来源:TaskSchedulerTest.cs

示例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);
                }
            }
        }
开发者ID:pakoito,项目名称:Fracture,代码行数:27,代码来源:DbTests.cs

示例5: QueueStep

 void ISchedulable.Schedule(TaskScheduler scheduler, IFuture future)
 {
     _Future = future;
     _Scheduler = scheduler;
     _Future.RegisterOnDispose(this.OnDisposed);
     QueueStep();
 }
开发者ID:pakoito,项目名称:Fracture,代码行数:7,代码来源:SchedulableGeneratorThunk.cs

示例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
                );
            }
        }
开发者ID:mbahar94,项目名称:fracture,代码行数:26,代码来源:DbTests.cs

示例7: LogWindow

        public LogWindow(TaskScheduler scheduler)
            : base(scheduler)
        {
            InitializeComponent();

            GC.Collect();
        }
开发者ID:kg,项目名称:shootbluesscripts,代码行数:7,代码来源:LogWindow.cs

示例8: RunSettingTaskDetail

        public RunSettingTaskDetail(TaskScheduler task)
        {
            InitializeComponent();
            this.LayoutRoot.DataContext = task;

            this.ContentTextBox.Text = this.GetParameterSettings(task);
        }
开发者ID:BlueSky007,项目名称:ExchangeManager,代码行数:7,代码来源:RunSettingTaskDetail.xaml.cs

示例9: Registration

            public Registration () {
                Scope = CancellationScope.Current;
                Scheduler = TaskScheduler.Current;

                if (Scheduler == null)
                    throw new InvalidOperationException("No implicitly active TaskScheduler on this thread.");
            }
开发者ID:sq,项目名称:Fracture,代码行数:7,代码来源:CancellationScope.cs

示例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();
            }
        }
开发者ID:endo0407,项目名称:IteratorTasks,代码行数:32,代码来源:TaskUtilityTest.cs

示例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;
    }
开发者ID:ppatoria,项目名称:SoftwareDevelopment,代码行数:7,代码来源:TaskSchedular.cs

示例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);
            }
        }
开发者ID:kg,项目名称:shootblues,代码行数:28,代码来源:ProcessWatcher.cs

示例13: HttpServer

        public HttpServer(TaskScheduler scheduler)
        {
            EndPoints = new EndPointList(this);

            Scheduler = scheduler;

            RequestOnComplete = _RequestOnComplete;
        }
开发者ID:sq,项目名称:Fracture,代码行数:8,代码来源:HttpServer.cs

示例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;
 }
开发者ID:bphermansson,项目名称:telldus,代码行数:9,代码来源:frmSchedule.cs

示例15: SchedulerProvider

 public SchedulerProvider()
 {
     Task = new TaskScheduler();
     IOCompletion = new IOCompletionScheduler();
     Current = new CurrentScheduler();
     Immediate = new ImmediateScheduler();
     NewThread = new NewThreadScheduler();
     ThreadPool = new ThreadPoolScheduler();
 }
开发者ID:ganesum,项目名称:Naru,代码行数:9,代码来源:SchedulerProvider.cs


注:本文中的TaskScheduler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。