• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TaskScheduler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TaskScheduler的典型用法代码示例。如果您正苦于以下问题:C# TaskScheduler类的具体用法?C# TaskScheduler怎么用?C# TaskScheduler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TaskScheduler类属于命名空间,在下文中一共展示了TaskScheduler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: Application_Start

        void Application_Start(object sender, EventArgs e)
        {
            XmlDocument xml = new XmlDocument();
            xml.Load(Server.MapPath(@"\config\tasks.config"));
            XmlNodeList nodes = xml.SelectNodes("Tasks/Task");

            this._scheduler = new TaskScheduler(nodes);
            this._scheduler.StartTasks();
        }
开发者ID:keyvan,项目名称:Abidar,代码行数:9,代码来源:Global.asax.cs


示例17: SetUp

        public void SetUp()
        {
            _tasks = CreateTasks();

            _timer = new Mock<ITimer>();
            _taskRunner = new Mock<ITaskRunner>();

            _taskScheduler = new TaskScheduler(_timer.Object, _taskRunner.Object);
        }
开发者ID:simax,项目名称:EmbeddedTaskScheduler,代码行数:9,代码来源:TaskSchedulerTests.cs


示例18: ArgumentNullException

        void ISchedulable.Schedule(TaskScheduler scheduler, IFuture future)
        {
            if (future == null)
                throw new ArgumentNullException("future");

            _Future = future;
            _Scheduler = scheduler;
            _Future.RegisterOnDispose(this.OnDisposed);
            QueueStep();
        }
开发者ID:sq,项目名称:Fracture,代码行数:10,代码来源:SchedulableGeneratorThunk.cs


示例19: GetParameterSettings

        private string GetParameterSettings(TaskScheduler task)
        {
            string parameterString = string.Empty;

            foreach (ParameterSettingTask setting in task.ParameterSettings)
            {
                parameterString += setting.ParameterKey + ":" + setting.ParameterValue;
            }
            return parameterString;
        }
开发者ID:BlueSky007,项目名称:ExchangeManager,代码行数:10,代码来源:RunSettingTaskDetail.xaml.cs


示例20: CommonApplication

        /// <summary>
        ///     Initialisiert eine neue Instanz der <see cref="CommonApplication" /> Klasse.
        /// </summary>
        /// <param name="doStartup">
        ///     The do startup.
        /// </param>
        /// <param name="service">
        ///     The service.
        /// </param>
        /// <param name="factory">
        ///     The factory.
        /// </param>
        protected CommonApplication(bool doStartup, [CanBeNull] ISplashService service, [NotNull] IUIControllerFactory factory)
        {
            Contract.Requires<ArgumentNullException>(factory != null, "factory");

            Factory = factory;
            Current = this;
            _scheduler = new TaskScheduler(UiSynchronize.Synchronize);
            _splash = service ?? new NullSplash();
            _doStartup = doStartup;
            SourceAssembly = new AssemblyName(Assembly.GetAssembly(GetType()).FullName).Name;
        }
开发者ID:Tauron1990,项目名称:Tauron-Application-Common,代码行数:23,代码来源:CommonApplication.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TaskState类代码示例发布时间:2022-05-24
下一篇:
C# TaskResult类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap