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


C# TaskScheduler.Start方法代码示例

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


在下文中一共展示了TaskScheduler.Start方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: Main

        static void Main (string[] args) {
            Scheduler = new TaskScheduler();

            World.Create();
            Event.Broadcast(new { Type = EventType.WorldConstructed });

            Server = new TelnetServer(Scheduler, System.Net.IPAddress.Any, 23);
            Scheduler.Start(HandleNewClients(), TaskExecutionPolicy.RunAsBackgroundTask);

            while (true) {
                Scheduler.Step();
                Scheduler.WaitForWorkItems();
            }
        }
开发者ID:mbahar94,项目名称:fracture,代码行数:14,代码来源:Program.cs

示例4: HeapRecording

        protected HeapRecording(
            TaskScheduler scheduler,
            ActivityIndicator activities,
            ProcessStartInfo startInfo
        )
        {
            StartInfo = startInfo;
            Activities = activities;

            Scheduler = scheduler;

            Futures.Add(Scheduler.Start(
                ProfileMainTask(), TaskExecutionPolicy.RunAsBackgroundTask
            ));

            DiffCache.ItemEvicted += DiffCache_ItemEvicted;
        }
开发者ID:konlil,项目名称:HeapProfiler,代码行数:17,代码来源:HeapRecording.cs

示例5: TagDatabase

        public TagDatabase(TaskScheduler scheduler, string filename)
        {
            Scheduler = scheduler;

            string connectionString = String.Format("Data Source={0}", filename);
            NativeConnection = new SQLiteConnection(connectionString);
            NativeConnection.Open();
            Connection = new ConnectionWrapper(scheduler, NativeConnection);

            CompileQueries();

            _TaskMap["GetSourceFileID"] = GetSourceFileID;

            #if DEBUG
            scheduler.Start(
                MemoizationHitRateLogger(), TaskExecutionPolicy.RunAsBackgroundTask
            );
            #endif
        }
开发者ID:BlackFrog1,项目名称:ndexer,代码行数:19,代码来源:TagDatabase.cs

示例6: TelnetServer

        public TelnetServer(TaskScheduler scheduler, IPAddress address, int port)
        {
            _Scheduler = scheduler;
            _Listener = new TcpListener(address, port);
            _Listener.Start();
            _ListenerTask = scheduler.Start(this.ListenTask(), TaskExecutionPolicy.RunWhileFutureLives);

            Console.WriteLine("Ready for connections.");
        }
开发者ID:sq,项目名称:Fracture,代码行数:9,代码来源:TelnetServer.cs

示例7: Main

        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            using (Scheduler = new TaskScheduler(JobQueue.WindowsMessageBased))
            using (ErrorList = new ErrorListDialog()) {
                Scheduler.ErrorHandler = OnTaskError;

                Preferences = new Tangle<object>(
                    Scheduler, CreatePreferencesStorage()
                );

                using (var f = Scheduler.Start(MainTask(), TaskExecutionPolicy.RunAsBackgroundTask)) {
                    f.RegisterOnComplete((_) => {
                        if (_.Failed)
                            Application.Exit();
                    });

                    Application.Run();
                }
            }
        }
开发者ID:kg,项目名称:HeapProfiler,代码行数:23,代码来源:Program.cs

示例8: TestDisposal

        public void TestDisposal()
        {
            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));

            TaskEnumerator<IDataRecord> iter;
            IFuture f;

            using (var scheduler = new TaskScheduler())
            using (var qm = new ConnectionWrapper(scheduler, Connection)) {
                var q = qm.BuildQuery("SELECT * FROM Test");
                var q2 = qm.BuildQuery("SELECT COUNT(*) FROM Test");
                iter = q.Execute();
                scheduler.Start(iter.Fetch());
                f = q2.ExecuteScalar();
            }

            iter.Dispose();

            try {
                int count = (int)f.Result;
                Assert.Fail("Future's result was not a ConnectionDisposedException");
            } catch (FutureException fe) {
                Assert.IsInstanceOfType(typeof(ConnectionDisposedException), fe.InnerException);
            }
        }
开发者ID:pakoito,项目名称:Fracture,代码行数:28,代码来源:DbTests.cs

示例9: TestTransactionAutoRollback

        public void TestTransactionAutoRollback()
        {
            DoQuery("CREATE TEMPORARY TABLE Test (value int)");

            using (var scheduler = new TaskScheduler())
            using (var qm = new ConnectionWrapper(scheduler, Connection)) {
                var getNumValues = qm.BuildQuery("SELECT COUNT(value) FROM test");

                var addValue = qm.BuildQuery("INSERT INTO test (value) VALUES (?)");

                var f = scheduler.Start(CrashyTransactionTask(qm, addValue));
                try {
                    scheduler.WaitFor(f);
                    Assert.Fail("Did not throw");
                } catch (FutureException fe) {
                    Exception inner = fe.InnerException;
                    Assert.IsInstanceOfType(typeof(InvalidOperationException), inner);
                }

                var fgnv = getNumValues.ExecuteScalar();
                long numValues = Convert.ToInt64(
                    scheduler.WaitFor(fgnv)
                );
                Assert.AreEqual(0, numValues);
            }
        }
开发者ID:pakoito,项目名称:Fracture,代码行数:26,代码来源:DbTests.cs

示例10: TestQueryPipelining

        public void TestQueryPipelining()
        {
            DoQuery("CREATE TEMPORARY TABLE Test (value int)");
            for (int i = 0; i < 100; i++)
                DoQuery(String.Format("INSERT INTO Test (value) VALUES ({0})", i));

            using (var scheduler = new TaskScheduler())
            using (var qm = new ConnectionWrapper(scheduler, Connection)) {
                var q1 = qm.BuildQuery("SELECT value FROM test");
                var q2 = qm.BuildQuery("INSERT INTO test (value) VALUES (?)");

                var iterator = q1.Execute();
                var f1 = scheduler.Start(iterator.Fetch());
                var f2 = q2.ExecuteNonQuery(200);

                f1.RegisterOnComplete((f) => {
                    Assert.IsNull(f.Error);
                    Assert.AreEqual(f1, f);
                    Assert.AreEqual(true, f.Result);
                    Assert.IsTrue(f1.Completed);
                    Assert.IsFalse(f2.Completed);
                });

                f2.RegisterOnComplete((f) => {
                    Assert.IsNull(f.Error);
                    Assert.AreEqual(f2, f);
                    Assert.IsTrue(f1.Completed);
                    Assert.IsTrue(f2.Completed);
                });

                scheduler.WaitFor(f1);

                scheduler.WaitFor(scheduler.Start(new Sleep(1.0)));
                Assert.IsFalse(f2.Completed);

                iterator.Dispose();

                scheduler.WaitFor(f2);
            }
        }
开发者ID:pakoito,项目名称:Fracture,代码行数:40,代码来源:DbTests.cs

示例11: Main

        static void Main(string[] argv)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (argv.Length < 1) {
                using (var dlg = new SaveFileDialog()) {
                    dlg.Title = "Select Index Database";
                    dlg.Filter = "Index Databases (*.db)|*.db";
                    dlg.CheckFileExists = false;
                    dlg.CheckPathExists = true;
                    dlg.AddExtension = true;
                    dlg.AutoUpgradeEnabled = true;
                    dlg.OverwritePrompt = false;

                    if (dlg.ShowDialog() != DialogResult.OK) {
                        MessageBox.Show(
                            "NDexer cannot start without a path specified for the index database on the command line.\n" +
                            @"For example: ndexer.exe C:\mysource\index.db",
                            "NDexer Error"
                        );
                        return;
                    } else {
                        DatabasePath = dlg.FileName;
                    }
                }
            } else {
                DatabasePath = System.IO.Path.GetFullPath(argv[0]);
            }

            if (System.IO.File.Exists(DatabasePath)) {
                if (System.IO.File.Exists(DatabasePath + "_new")) {
                    System.IO.File.Move(DatabasePath, DatabasePath + "_old");
                    System.IO.File.Move(DatabasePath + "_new", DatabasePath);
                    System.IO.File.Delete(DatabasePath + "_old");
                }
            } else {
            }

            Scheduler = new TaskScheduler(JobQueue.WindowsMessageBased);

            Database = new TagDatabase(Scheduler, DatabasePath);

            InitUI();

            Scheduler.Start(
                MainTask(argv),
                TaskExecutionPolicy.RunAsBackgroundTask
            );

            Application.Run();
        }
开发者ID:pazjacket,项目名称:malys-_-NDexer,代码行数:52,代码来源:Program.cs


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