Click here to Skip to main content
15,913,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

to get selected path files and folder count i have used below code
C#
var tCmbGetCount = Task.Factory.StartNew(() =>
{
	Task innerCmbGetCount = Task.Factory.StartNew(() => GetCount());
	innerCmbGetCount.Wait();
	return innerCmbGetCount; 
});

C#
public long GetCount()
{
	try
	{
		 //calculate selected path file and folder count and assign to label

		lblFolderCount.Text = strFinalFolderCalc.ToString();
		lblFileCount.Text = strFinalFileCalc.ToString();

		return strFinalFolderCalc;
	}
	catch (System.Exception ex)
	{ 
		return 0;
	}
}

but i need to stop task before start.
How to do it
Posted
Updated 3-Dec-14 1:54am
v2
Comments
Praveen Kumar Upadhyay 3-Dec-14 8:12am    
Stop Task before start??
What does it mean??

1 solution

Use below code wherever you want to cancel the Task.

C#
innerCmbGetCount.Cancel();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900