本文整理汇总了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();
}
示例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);
}
示例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();
}
示例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");
}
}