Click here to Skip to main content
15,942,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my codes as follows:

public delegate int DelegateFun(int a,int b);
DelegateFun dl = DataProcess;//DataProcess is a data procss function,and there is a block function in it
int a = 3;
int b= 4;
dl.BeginInvoke(a,b,null,null);

then,how i force to interrupt the DataProcess's running beforce it finish?

do i force to interrupt it as Thread using Thread.Abort?

What I have tried:

i look for solutions in network,someone said delegate function run in threadpool,so we don't control it.
Posted
Updated 4-Jul-16 18:11pm
Comments
Philippe Mori 6-Jul-16 11:25am    
Never do that. If you need to abort your process, then implement cooperative stopping by signaling somehow to the process to terminate and then wait until the process returns.
SteveHolle 8-Jul-16 11:31am    
You could use a BackgroundWorker which allows cancelation.

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