Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

how to run async void function c#

// 100% working!!
async Task hello() // THIS IS FAKE ASYNC VOID FUNC
{
	List<Task> tasks = new List<Task>{
		new Task(console),
		new Task(console),
	};
	foreach(Task func in tasks)
	{
		func.Start();
	}
	Task empty = new Task(a);
	empty.Start();
	await empty; // DO NOTHING / EMPTINESS
	Console.WriteLine("Finished");
}
int num ;
void console() // RUNNING IN PARALLEL
{
	num++;
	for (int i = 0; i != 100 ; i++)
	{
		Console.WriteLine(i);
	}
	Console.WriteLine("console" + num.ToString() + " has been finished");
}
void a() // to kill the HELLO process
{
}
hello().Wait(); // running ASYNC FUNC
 
PREVIOUS NEXT
Tagged: #run #async #void #function
ADD COMMENT
Topic
Name
5+8 =