c# - Multi thread is created when called inside a delegate? -
i have created file upload windows application in c#. have problem, using delegate function starting new thread file upload. it's works fine, happens instead of creating single thread, created 2 thread 1 after another. call delegate function , inside function starting new thread. when debugging found out delegate function called once, thread.start calling multiple times. please find code flow
public delegate void calltransactionstartdelegate(int transid); private wts_manager privateui = new wts_manager(); function starttrans() { calltransactionstartdelegate dlgstartmanualtrans = new calltransactionstartdelegate (privateui.startmanualtransaction); loginfo.writelogsinformation("before calling startmanualtransaction method"); privateui.invoke(dlgstartmanualtrans,new object[]{txid}); } wts_manager form class code ---------------------- public void startmanualtransaction(int transid) { loginfo.writelogsinformation("inside startmanualtransaction method"); new fileupload(transid,this).start(); } fileupload class file ---------------------- public fileupload(int transid, wts_manager parentui) { // initialised code here.. } public void start() { loginfo.writelogsinformation("inside fileupload start method"); thread th = new thread(new threadstart(startupload)); th.start(); } public void startupload() { loginfo.writelogsinformation("inside startupload method"); // have written code file upload.. }
here written in log file
11/10/2016 6:21:55 pm threadid :- 7 processid :- 380 before calling startmanualtransaction method 11/10/2016 6:21:55 pm threadid :- 1 processid :- 380 inside startmanualtransaction method 11/10/2016 6:21:55 pm threadid :- 1 processid :- 380 inside fileupload start method 11/10/2016 6:21:55 pm threadid :- 8 processid :- 380 inside startupload method 11/10/2016 6:21:57 pm threadid :- 11 processid :- 380 inside startupload method
i not able understand why 2 threads created?
rajagopalan
Comments
Post a Comment