sendkeys - vb.net multi process -
here scenario, have 2 sendkeys application (using timer) , rewrite one, im having problem, example, if enable timer1 send lots of "q" until stop it, if enabled timer2 send "1" "2" "3". output of process
qqqqq123q123q123q123q123q123
and it's not wanted, before merge 2 sendkeys output me this
qqqq1qqq2qq3qqqqqq1q2q3qqqq1
both timer have same interval. thing happen when merge 2 timer in 1 runnnig application timer1 timer2 timer1 again, alternating process instead of doing in same time. hope can me. thx
take @ reference: http://msdn.microsoft.com/en-us/library/system.windows.forms.timer.aspx
it says:
this windows timer designed single-threaded environment ui threads used perform processing
so single threaded, intervals of timer same. behandled sequentially. should use system.threading.thread instead. see example below. make paramaterized thread object takes string argument sendkeys should send on thread. , start two, or more threads.
using system; using system.threading; // simple threading scenario: start static method running // on second thread. public class threadexample { // threadproc method called when thread starts. // loops ten times, writing console , yielding // rest of time slice each time, , ends. public static void threadproc() { (int = 0; < 10; i++) { console.writeline("threadproc: {0}", i); // yield rest of time slice. thread.sleep(0); } } public static void main() { console.writeline("main thread: start second thread."); // constructor thread class requires threadstart // delegate represents method executed on // thread. c# simplifies creation of delegate. thread t = new thread(new threadstart(threadproc)); // start threadproc. note on uniprocessor, new // thread not processor time until main thread // preempted or yields. uncomment thread.sleep // follows t.start() see difference. t.start(); //thread.sleep(0); (int = 0; < 4; i++) { console.writeline("main thread: work."); thread.sleep(0); } console.writeline("main thread: call join(), wait until threadproc ends."); t.join(); console.writeline("main thread: threadproc.join has returned. press enter end program."); console.readline(); } }
this example came from: http://msdn.microsoft.com/en-us/library/system.threading.thread.aspx
Comments
Post a Comment