AsyncOverSimplified.SimpleAsyncWorker.DoWorkWithoutAwait C# (CSharp) Method

DoWorkWithoutAwait() public method

public DoWorkWithoutAwait ( ) : Task
return Task
        public Task<int> DoWorkWithoutAwait()
        {
            int count = 0;

            Task<int> countTask = GetCountAsync("x");

            Task<int> final =
            countTask.ContinueWith(_ =>
            {
                int result = countTask.Result;
                count = count + result;
                Console.WriteLine("X Count is " + count);
                return count;
            });

            return final;
        }

Usage Example

コード例 #1
0
ファイル: Program.cs プロジェクト: negativeeddy/blog-examples
 /// <summary>
 /// Runs all 3 variations of the Simple code to ensure
 /// they all have the same result
 /// </summary>
 /// <returns></returns>
 static async Task SimpleMainAsync()
 {
     var worker = new SimpleAsyncWorker();
     await worker.DoWork();
     await worker.DoWorkExplicitTasks();
     await worker.DoWorkWithoutAwait();
 }
All Usage Examples Of AsyncOverSimplified.SimpleAsyncWorker::DoWorkWithoutAwait