Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# write to output window 
Csharp :: c# turn negative number into positive 
Csharp :: unity audio 
Csharp :: roman to int 
Csharp :: array join c# 
Csharp :: c# int array 
Csharp :: c# enum default 
Csharp :: fluent assertions exception 
Csharp :: unity find object by name 
Csharp :: generate qr code c# 
Csharp :: c# and in if statement 
Csharp :: unity find child by name 
Csharp :: new ienumerable 
Csharp :: c# create tasks and wait all 
Csharp :: c# open file for reading and writing 
Csharp :: how to add headers to scripts in unity 
Csharp :: c# get all namespaces in assembly 
Csharp :: convert object to httpcontent c# 
Csharp :: what are access modifiers in c# 
Csharp :: how to convert object in string JSON c# 
Csharp :: c# kill one excel process 
Csharp :: wpf get function name 
Csharp :: c# .net 3.5 post json httpclient 
Csharp :: c# datetime blank 
Csharp :: cast char[] to string c# 
Csharp :: c# clear an array 
Csharp :: char array 
Csharp :: c# debug writeline 
Csharp :: primitive types c# 
Csharp :: take space separated input in c# 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =