本文整理汇总了C#中System.Threading.ManualResetEvent.WaitOrThrowOnTimeout方法的典型用法代码示例。如果您正苦于以下问题:C# ManualResetEvent.WaitOrThrowOnTimeout方法的具体用法?C# ManualResetEvent.WaitOrThrowOnTimeout怎么用?C# ManualResetEvent.WaitOrThrowOnTimeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Threading.ManualResetEvent
的用法示例。
在下文中一共展示了ManualResetEvent.WaitOrThrowOnTimeout方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldCreateDatabaseAddDocumentToItReplicateAndRead
public void ShouldCreateDatabaseAddDocumentToItReplicateAndRead()
{
var dbA = "db_" + Guid.NewGuid();
var dbB = "db_" + Guid.NewGuid();
var savedDocument = Entity.CreateDocWithoutRevision();
var couchApi = (ICouchApi) new CouchApi(new CouchApiSettings("http://127.0.0.1:5984/"), null);
couchApi.Db(dbA).Synchronously.Create();
var docInfo = couchApi.Db(dbA).Synchronously.SaveDocument(savedDocument);
couchApi.Db(dbB).Synchronously.Create();
var replicationDescriptorId = dbA + "_to_" + dbB;
var replicationTaskDescriptor = new ReplicationTaskDescriptor {
Id = replicationDescriptorId,
Target = new Uri(dbB, UriKind.Relative),
Source = new Uri(dbA, UriKind.Relative)
};
couchApi.Replicator.Synchronously.SaveDescriptor(replicationTaskDescriptor);
var replicationDoneEvent = new ManualResetEvent(false);
WatchForReplicationToFinish(
() => couchApi.Replicator.RequestDescriptorById(replicationDescriptorId), replicationDoneEvent);
replicationDoneEvent.WaitOrThrowOnTimeout();
var loadedDocument = couchApi.Db(dbB).Synchronously.RequestDocument(savedDocument.Id);
Assert.Equal(savedDocument.Id, loadedDocument.Id);
Assert.Equal(docInfo.Revision, loadedDocument.Revision);
couchApi.Replicator.DeleteDescriptor(replicationTaskDescriptor);
couchApi.Db(dbA).Synchronously.Delete();
couchApi.Db(dbB).Synchronously.Delete();
}