Beispiel #1
0
        public void TestTimingOutATask()
        {
            var sut    = new TaskExample();
            var result = sut.TimingOutATask();

            Assert.AreEqual(0, result);
        }
Beispiel #2
0
        public void TestWaitAny()
        {
            var sut    = new TaskExample();
            var result = sut.WaitAny();

            Assert.AreEqual(6, result);
        }
Beispiel #3
0
        public void TestChildTasks()
        {
            var sut    = new TaskExample();
            var result = sut.ChildTasks();

            Assert.AreEqual(3, result);
        }
Beispiel #4
0
        public void TestTaskFactory()
        {
            var sut    = new TaskExample();
            var result = sut.TaskFactory();

            Assert.AreEqual(3, result);
        }
Beispiel #5
0
        public void TestCancellingATask()
        {
            var sut    = new TaskExample();
            var result = sut.CancellingATask();

            Assert.AreEqual(true, result);
        }
Beispiel #6
0
        public void TestNewAndStart()
        {
            var sut = new TaskExample();

            sut.StartAndWait();

            Assert.IsTrue(sut.IsSet);
        }
Beispiel #7
0
        public void TestResult()
        {
            var sut    = new TaskExample();
            var result = sut.Result();

            Assert.IsTrue(sut.IsSet);
            Assert.IsTrue(result);
        }
Beispiel #8
0
        public void TestContinuationTask()
        {
            var sut    = new TaskExample();
            var result = sut.ContinuationTask();

            Assert.IsTrue(sut.IsSet);
            Assert.IsFalse(result);
        }
Beispiel #9
0
        public void TestStartNew()
        {
            var sut = new TaskExample();

            sut.StartNew();

            Assert.IsTrue(sut.IsSet);
        }
Beispiel #10
0
        public void TestContinuationTaskAgain()
        {
            var sut    = new TaskExample();
            var result = sut.ContinuationTaskAgain();

            Assert.IsTrue(sut.IsSet);
            Assert.AreEqual("OnlyOnRanToCompletion", result);
        }
Beispiel #11
0
        public void TestStartAndRunSynchronously()
        {
            var sut = new TaskExample();

            sut.RunSynchronously();

            Assert.IsTrue(sut.IsSet);
        }
Beispiel #12
0
        public void Configuration(IAppBuilder app)
        {
            app.UseHangfireServer();
            app.UseHangfireDashboard(string.Empty);

            var taskExample = new TaskExample();

            RecurringJob.AddOrUpdate(() => taskExample.TaskMethod(null), Cron.Minutely);
        }
Beispiel #13
0
 public TasksDictionary(string name, int lvls, GameType game, int num)
 {
     orderNumber   = ++num;
     gameType      = game;
     this.name     = name;
     localizedName = name;
     Levels        = new TaskExample[lvls];
     for (int i = 0; i < Levels.Length; i++)
     {
         Levels[i] = new TaskExample(i);
     }
 }
Beispiel #14
0
        static void Main(string[] args)
        {
            var exampleToRun = ExamplesEnumeration.MultipleParameters;

            switch (exampleToRun)
            {
            case ExamplesEnumeration.BasicTask:
                TaskExample.ShowTask();
                break;

            case ExamplesEnumeration.WithParameters:
                TaskExample.ShowTaskWithParameters();
                break;

            case ExamplesEnumeration.TaskStatus:
                TaskExample.ShowTaskStatus();
                break;

            case ExamplesEnumeration.IsBackground:
                IsBackgroupExample.ShowIsBackground();
                break;

            case ExamplesEnumeration.Wait:
                WaitExample.ShowWaitTask();
                break;

            case ExamplesEnumeration.WaitAllOrAny:
                WaitExample.ShowWaitAllOrAny();
                break;

            case ExamplesEnumeration.TaskFactory:
                TaskFactoryExample.ShowTaskFactory();
                break;

            case ExamplesEnumeration.ContinueWith:
                TaskContinuationExample.ShowTaskContinuation();
                break;

            case ExamplesEnumeration.Result:
                TaskResultExample.ShowTaskResult();
                break;

            case ExamplesEnumeration.MultipleParameters:
                MultipleParametersExample.ShowMultipleParameters();
                break;
            }

            Console.Read();
        }
Beispiel #15
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            ApplicationLogging.LoggerFactory = loggerFactory;

            app.UseHangfireServer();
            app.UseHangfireDashboard(string.Empty);

            var taskExample = new TaskExample();

            RecurringJob.AddOrUpdate(() => taskExample.TaskMethod(null), Cron.Minutely);
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHangfireServer();
            app.UseHangfireDashboard();

            app.Run(async(context) =>
            {
                await context.Response.WriteAsync("Hello World!");
            });

            var taskExample = new TaskExample();

            RecurringJob.AddOrUpdate(() => taskExample.TaskMethod(null), Cron.Minutely);
        }
        private static void Lesson3()
        {
            //CHECKTHAT!!!!!!!!!!! MutexExample.DoWork();
            Console.WriteLine($"Main thread id#{Thread.CurrentThread.ManagedThreadId}");
            //TaskExample.DoColdTask();
            //TaskExample.DoHotTask();
            //TaskExample.DoTaskWithContinuation();
            //TaskExample.DoTaskWithCatchingException();

            /*var task = TaskExample.DivideAsync(5, 3);
             * Console.WriteLine(task.Result);*/

            CancellationTokenSource cts = new CancellationTokenSource();

            Task.Run(() => {
                Thread.Sleep(3000);
                cts.Cancel();
            });

            TaskExample.CalculateWithCancellation(cts.Token);
            cts.Cancel();
        }
Beispiel #18
0
 public void SetUpNode()
 {
     node = new TaskExample();
 }
Beispiel #19
0
 public void CreateTask()
 {
     task = new TaskExample();
 }