本文整理汇总了C#中System.Threading.Tasks类的典型用法代码示例。如果您正苦于以下问题:C# System.Threading.Tasks类的具体用法?C# System.Threading.Tasks怎么用?C# System.Threading.Tasks使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Threading.Tasks类属于命名空间,在下文中一共展示了System.Threading.Tasks类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Urls
[U] public async Task Urls()
{
await POST("/_tasks/_cancel")
.Fluent(c => c.CancelTasks())
.Request(c => c.CancelTasks(new CancelTasksRequest()))
.FluentAsync(c => c.CancelTasksAsync())
.RequestAsync(c => c.CancelTasksAsync(new CancelTasksRequest()))
;
var taskId = "node:4";
await POST($"/_tasks/node%3A4/_cancel")
.Fluent(c => c.CancelTasks(t=>t.TaskId(taskId)))
.Request(c => c.CancelTasks(new CancelTasksRequest(taskId)))
.FluentAsync(c => c.CancelTasksAsync(t=>t.TaskId(taskId)))
.RequestAsync(c => c.CancelTasksAsync(new CancelTasksRequest(taskId)))
;
var nodes = new []{ "node1", "node2" };
var actions = new[] { "*reindex" };
await POST($"/_tasks/_cancel?node_id=node1%2Cnode2&actions=%2Areindex")
.Fluent(c => c.CancelTasks(t => t.NodeId(nodes).Actions(actions)))
.Request(c => c.CancelTasks(new CancelTasksRequest { NodeId = nodes, Actions = actions }))
.FluentAsync(c => c.CancelTasksAsync(t => t.NodeId(nodes).Actions(actions)))
.RequestAsync(c => c.CancelTasksAsync(new CancelTasksRequest { NodeId = nodes, Actions = actions }))
;
}
示例2: Version_should_be_compatible
public async Task Version_should_be_compatible()
{
// This isn't really a test.
// It's here for my own record keeping,
// if something breaks I'll know the last good version from
// test/git history
var supportedVersions = new[]
{
//"0.22.0",
//"0.25.0",
//"0.26.0",
//"0.27.0",
//"0.28.0",
// Broken at 0.29.0
//"0.29.0",
//"0.30.0",
//"0.31.0",
// Pin messages broken, different return room lookup
"0.32.0",
"0.33.0",
"0.34.0",
"0.35.0",
};
await DefaultAccountLoginAsync();
// Act
var results = await RocketChatDriver.GetStatisticsAsync();
// Assert
supportedVersions.Should().Contain(results.Result.Version);
}
示例3: ChangeSignature_Formatting_Method
public async Task ChangeSignature_Formatting_Method()
{
var markup = @"
class C
{
void $$Method(int a,
int b)
{
Method(1,
2);
}
}";
var updatedSignature = new[] { 1, 0 };
var expectedUpdatedCode = @"
class C
{
void Method(int b,
int a)
{
Method(2,
1);
}
}";
await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: updatedSignature, expectedUpdatedInvocationDocumentCode: expectedUpdatedCode);
}
示例4: ChangeSignature_Formatting_KeepCountsPerLine
public async Task ChangeSignature_Formatting_KeepCountsPerLine()
{
var markup = @"
class C
{
void $$Method(int a, int b, int c,
int d, int e,
int f)
{
Method(1,
2, 3,
4, 5, 6);
}
}";
var updatedSignature = new[] { 5, 4, 3, 2, 1, 0 };
var expectedUpdatedCode = @"
class C
{
void Method(int f, int e, int d,
int c, int b,
int a)
{
Method(6,
5, 4,
3, 2, 1);
}
}";
await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: updatedSignature, expectedUpdatedInvocationDocumentCode: expectedUpdatedCode);
}
示例5: ChangeSignature_Formatting_Constructor
public async Task ChangeSignature_Formatting_Constructor()
{
var markup = @"
class SomeClass
{
$$SomeClass(int a,
int b)
{
new SomeClass(1,
2);
}
}";
var updatedSignature = new[] { 1, 0 };
var expectedUpdatedCode = @"
class SomeClass
{
SomeClass(int b,
int a)
{
new SomeClass(2,
1);
}
}";
await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: updatedSignature, expectedUpdatedInvocationDocumentCode: expectedUpdatedCode);
}
示例6: ReorderParameters_Cascade_ToImplementingMethod
public async Task ReorderParameters_Cascade_ToImplementingMethod()
{
var markup = @"
interface I
{
$$void M(int x, string y);
}
class C : I
{
public void M(int x, string y)
{ }
}";
var permutation = new[] { 1, 0 };
var updatedCode = @"
interface I
{
void M(string y, int x);
}
class C : I
{
public void M(string y, int x)
{ }
}";
await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode);
}
示例7: FilterAndGroupDocuments
public async Task FilterAndGroupDocuments()
{
// @begin: filter-and-group-documents
// @code: start
var collection = _database.GetCollection<BsonDocument>("restaurants");
var aggregate = collection.Aggregate()
.Match(new BsonDocument { { "borough", "Queens" }, { "cuisine", "Brazilian" } })
.Group(new BsonDocument { { "_id", "$address.zipcode" }, { "count", new BsonDocument("$sum", 1) } });
var results = await aggregate.ToListAsync();
// @code: end
// @results: start
var expectedResults = new[]
{
BsonDocument.Parse("{ _id : '11368', count : 1 }"),
BsonDocument.Parse("{ _id : '11106', count : 3 }"),
BsonDocument.Parse("{ _id : '11377', count : 1 }"),
BsonDocument.Parse("{ _id : '11103', count : 1 }"),
BsonDocument.Parse("{ _id : '11101', count : 2 }")
};
results.Should().BeEquivalentTo(expectedResults);
// @results: end
// @end: filter-and-group-documents
}
示例8: Serialize_ResourceCollectionDocument_for_primary_data_only_and_metadata
public async Task Serialize_ResourceCollectionDocument_for_primary_data_only_and_metadata()
{
var primaryData1 = new Mock<IResourceObject>(MockBehavior.Strict);
var primaryData2 = new Mock<IResourceObject>(MockBehavior.Strict);
var mockResourceObjectFormatter = new Mock<IResourceObjectFormatter>(MockBehavior.Strict);
mockResourceObjectFormatter.Setup(m => m.Serialize(primaryData1.Object, It.IsAny<JsonWriter>()))
.Returns((IResourceObject resourceObject, JsonWriter writer) =>
{
writer.WriteValue("Primary data 1");
return Task.FromResult(0);
});
mockResourceObjectFormatter.Setup(m => m.Serialize(primaryData2.Object, It.IsAny<JsonWriter>()))
.Returns((IResourceObject resourceObject, JsonWriter writer) =>
{
writer.WriteValue("Primary data 2");
return Task.FromResult(0);
});
var mockMetadata = new Mock<IMetadata>(MockBehavior.Strict);
var mockMetadataFormatter = new Mock<IMetadataFormatter>(MockBehavior.Strict);
mockMetadataFormatter.Setup(m => m.Serialize(mockMetadata.Object, It.IsAny<JsonWriter>()))
.Returns((IMetadata resourceObject, JsonWriter writer) =>
{
writer.WriteValue("Placeholder metadata object");
return Task.FromResult(0);
});
var primaryData = new[] { primaryData1.Object, primaryData2.Object };
IResourceCollectionDocument document = new ResourceCollectionDocument(primaryData, null, mockMetadata.Object);
var formatter = new ResourceCollectionDocumentFormatter(mockResourceObjectFormatter.Object, mockMetadataFormatter.Object);
await AssertSerializeOutput(formatter, document, "Json/Fixtures/ResourceCollectionDocumentFormatter/Serialize_ResourceCollectionDocument_for_primary_data_only_and_metadata.json");
}
示例9: should_retrieve_builds_for_all_available_devices
public async void should_retrieve_builds_for_all_available_devices()
{
var inputDevice = Substitute.For<IInputDevice>();
var connection = Substitute.For<ITeamCityConnection>();
connection.GetBuild(Arg.Any<string>()).ReturnsForAnyArgs("<builds />");
var outputDevice1 = Substitute.For<IOutputDevice>();
outputDevice1.IsAvailable.Returns(true);
var inputs1 = new[] { buildId1, buildId2 };
var outputDevice2 = Substitute.For<IOutputDevice>();
outputDevice2.IsAvailable.Returns(false);
var inputs2 = new[] { buildId3 };
var monitor = new TeamCityMonitor(inputDevice, d => connection);
monitor.AddBuilds(outputDevice1, inputs1);
monitor.AddBuilds(outputDevice2, inputs2);
await monitor.BeginMonitoring();
await Task.WhenAll(
connection.Received().GetBuild(buildId1),
connection.Received().GetBuild(buildId2),
connection.DidNotReceive().GetBuild(buildId3));
}
示例10: UpdateRequest
public IndividualRequestResponse UpdateRequest(Request request, Comment comment=null)
{
if (comment != null)
request.Comment = comment;
var body = new { request };
return GenericPut<IndividualRequestResponse>(string.Format("requests/{0}.json", request.Id.Value), body);
}
示例11: Poll
public Task<object> Poll(int topicId)
{
var model = new
{
topicId
};
return Request<object>(model);
}
示例12: Update
/// <summary>
/// Creates or updates the reminder on a object. Possible ref_types are: task.
/// <para>Podio API Reference: https://developers.podio.com/doc/reminders/create-or-update-reminder-3315055 </para>
/// </summary>
/// <param name="refType">Type of the reference.</param>
/// <param name="refId">The reference identifier.</param>
/// <param name="remindDelta">minutes to remind before the due date of the object</param>
/// <returns>Task.</returns>
public Task Update(string refType, int refId, int remindDelta)
{
string url = string.Format("/reminder/{0}/{1}", refType, refId);
dynamic requestData = new
{
remind_delta = remindDelta
};
return _podio.PutAsync<dynamic>(url, requestData);
}
示例13: Post
public Task<JwtCredentials> Post(string key, string secret, string userId)
{
var data = new
{
key,
secret
};
return CreateCredentials(data);
}
示例14: GetUserAliases
public Task<object> GetUserAliases(long membershipId)
{
var model = new
{
membershipId
};
return Request<object>(model);
}
示例15: SearchUsers
public Task<object> SearchUsers(string search)
{
var model = new
{
search
};
return Request<object>(model);
}