// -----------------------------------------------------------------------
// <copyright file="LoadSimulator.cs" company="Microsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Threading.Tasks;
namespace SampleExercises
{
static class LoadSimulator
{
public static int i = 10;
static void Main(string[] args)
{
string status = "";
//Task with return status
Task<string> ThreadsCreation = Task<string>.Factory.StartNew(() =>
{
status = methodA();
return status;
});
//Wait for Task Completion
ThreadsCreation.Wait();
Console.WriteLine("Status value is " + status);
Console.ReadLine();
//Taskwith no return status
var noReturnTask = new Task(() => methodB());
//Start The Task
noReturnTask.Start();
Console.ReadLine();
}
public static string methodA()
{Console.WriteLine("i count is" + i++);
return i.ToString();
}
public static void methodB()
{
Console.WriteLine(" This is am empty Task");
}
}
}
Happy Learning!!!
No comments:
Post a Comment