c# - ThreadAbortException when Task calls method in service reference -
i need call method in service reference name canceltransactionbyrefpos. method has following signature:
int canceltransactionbyrefpos(long refpos, out string resultdescription);
if method returns '0' cancel succeeded. if method returns value, method has called again.
i have written cancel method calls canceltransactionbyrefpos. important call happens asynchronous because can take 30 seconds till response given.
my method looks like:
public void cancel(long refpos, giftcard giftcard, account_3_2 account) { var task = task.factory.startnew(() => { int result; { string resultdescription; result = _client.canceltransactionbyrefpos(refpos, out resultdescription); // logic log result giftcard , account parameter } while (result != 0); }); // task.wait(); // ######## uncomment -> code executes! ######## }
when cancel task.wait() part in comment, threadabortexception.
when uncomment task.wait() , execute again, doing if have wait until task executed, there no use calling method asynchronous.
edit
i have configurated service reference allows generation of asynchronous operations. same problem.
Comments
Post a Comment