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


C# Configuration.StartBackgroundWork方法代码示例

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


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

示例1: Background_tasks_that_return_disposables_have_their_disposables_disposed_with_the_Configuration

        public void Background_tasks_that_return_disposables_have_their_disposables_disposed_with_the_Configuration()
        {
            var configuration = new Configuration();
            var disposable = new BooleanDisposable();

            configuration.QueueBackgroundWork(c => disposable);

            configuration.StartBackgroundWork();

            disposable.IsDisposed.Should().BeFalse();

            configuration.Dispose();

            disposable.IsDisposed.Should().BeTrue();
        }
开发者ID:charlesmccarthyirl,项目名称:Its.Cqrs,代码行数:15,代码来源:ConfigurationTests.cs

示例2: Background_work_cannot_not_be_started_more_than_once

        public void Background_work_cannot_not_be_started_more_than_once()
        {
            var configuration = new Configuration();

            var startCount = 0;

            configuration.QueueBackgroundWork(c => Interlocked.Increment(ref startCount));

            configuration.StartBackgroundWork();
            configuration.StartBackgroundWork();

            startCount.Should().Be(1);
        }
开发者ID:charlesmccarthyirl,项目名称:Its.Cqrs,代码行数:13,代码来源:ConfigurationTests.cs

示例3: Background_work_starts_when_StartBackgroundWork_is_called

        public void Background_work_starts_when_StartBackgroundWork_is_called()
        {
            var configuration = new Configuration();

            var started = false;

            configuration.QueueBackgroundWork(c => { started = true; });

            configuration.StartBackgroundWork();

            started.Should().BeTrue();
        }
开发者ID:charlesmccarthyirl,项目名称:Its.Cqrs,代码行数:12,代码来源:ConfigurationTests.cs

示例4: Cleanup_can_be_scheduled_periodically

        public void Cleanup_can_be_scheduled_periodically()
        {
            var clock = VirtualClock.Current;

            clock.AdvanceTo(DateTimeOffset.Parse("2046-06-07 07:07:41 PM"));

            // arrange: set up some test data
            WriteScheduledCommand(
                finalAttemptTime: null,
                appliedTime: Clock.Now().Subtract(10.Days()),
                dueTime: Clock.Now().Subtract(100.Days()));

            // act
            Enumerable.Range(1, 10)
                      .ForEach(_ =>
                      {
                          clock.AdvanceBy(1.Days());

                          var configuration = new Configuration()
                              .UseSqlStorageForScheduledCommands(
                                  c => c.UseConnectionString(TestDatabases.CommandScheduler.ConnectionString)
                                        .CleanUp(
                                            frequencyInDays: 3,
                                            completedCommandsOlderThan: 7.Days()));

                          configuration.StartBackgroundWork();
                      });

            using (var db = Configuration.Current.CommandSchedulerDbContext())
            {
                var appliedMigrations = db.Database
                    .SqlQuery<string>(@"
select MigrationVersion from PocketMigrator.AppliedMigrations
where MigrationScope = 'CommandSchedulerCleanup'");

                appliedMigrations   
                    .Should()
                    .BeEquivalentTo("2046.6.7",
                                    "2046.6.10",
                                    "2046.6.13",
                                    "2046.6.16");
            }
        }
开发者ID:KimberlyPhan,项目名称:Its.Cqrs,代码行数:43,代码来源:SqlCommandSchedulerDatabaseCleanupTests.cs


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