c# - Execute web service method and return immediately -
c# asp.net 3.5
is possible "fire , forget" method in web service not asynchronous or one-way?
there method returns value (after processing), don't need. used group (who wrote service). basically, notifies user x did action y. need call method , move on without waiting result.
i tried using backgroundworker() runworkerasync, method not fire reason. cannot change web service method have no access code. should using backgroundworker, invoke, threadpool, else? don't need result returned, , don't need know if fails. basically, call method, , if works, great. if not, don't want stop or slow processing down.
public static void test() { var worker = new backgroundworker(); worker.dowork += test2; worker.runworkerasync(new object[] {12345, "test"}); } private static void test2(object sender, doworkeventargs e) { // write log got method - not object[] args = e.argument object[]; int num = convert.toint32(args[0]); string name = (string)args[1]; // call web service method here.... }
intsead of using background worker can try following
public static void test() { system.threading.threadpool.queueuserworkitem(delegate { test2(new object[] { 12345, "test" }); }); } private static void test2(object data) { // write log got method - not object[] args = data object[]; int num = convert.toint32(args[0]); string name = (string)args[1]; // call web service method here.... }
Comments
Post a Comment