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


C# Threading.Tasks类代码示例

本文整理汇总了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 }))
				;
		}
开发者ID:niemyjski,项目名称:elasticsearch-net,代码行数:26,代码来源:TasksCancelUrlTests.cs

示例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);
        }
开发者ID:RocketChat,项目名称:Rocket.Chat.Net,代码行数:33,代码来源:AdministrationFacts.cs

示例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);
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:25,代码来源:ChangeSignature_Formatting.cs

示例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);
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:29,代码来源:ChangeSignature_Formatting.cs

示例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);
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:25,代码来源:ChangeSignature_Formatting.cs

示例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);
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:28,代码来源:ReorderParametersTests.Cascading.cs

示例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
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:25,代码来源:AggregatePrimer.cs

示例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");
        }
开发者ID:BradBarnich,项目名称:JSONAPI.NET,代码行数:33,代码来源:ResourceCollectionDocumentFormatterTests.cs

示例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));
        }
开发者ID:JRoughan,项目名称:Emanate,代码行数:25,代码来源:teamcity_monitor.cs

示例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);
 }
开发者ID:bjerggaard,项目名称:ZendeskApi_v2,代码行数:8,代码来源:Requests.cs

示例11: Poll

        public Task<object> Poll(int topicId)
        {
            var model = new
            {
                topicId
            };

            return Request<object>(model);
        }
开发者ID:kodefuguru,项目名称:bungie,代码行数:9,代码来源:ForumService.cs

示例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);
		}
开发者ID:AjmalVh,项目名称:PodioPCL,代码行数:17,代码来源:ReminderService.cs

示例13: Post

 public Task<JwtCredentials> Post(string key, string secret, string userId)
 {
     var data = new
     {
         key,
         secret
     };
     return CreateCredentials(data);
 }
开发者ID:trackmatic,项目名称:kong.net,代码行数:9,代码来源:JwtPluginRequestFactory.cs

示例14: GetUserAliases

        public Task<object> GetUserAliases(long membershipId) 
        {
            var model = new
            {
                membershipId
            };

            return Request<object>(model); 
        }
开发者ID:kodefuguru,项目名称:bungie,代码行数:9,代码来源:UserService.cs

示例15: SearchUsers

        public Task<object> SearchUsers(string search) 
        {
            var model = new
            {
                search
            };

            return Request<object>(model); 
        }
开发者ID:kodefuguru,项目名称:bungie,代码行数:9,代码来源:UserService.cs


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