UBOTEM 18 Posted December 30, 2015 Report Share Posted December 30, 2015 Hello to all I am getting a little frustrated, and wondered if someone can confirm is working or not?! Ubot 4 and normal multithread is fine and working for me.Ubot 4 and Smart Threading is also working fine. Now I want to move to Ubot 5, mainly due to the fact it is faster to work with....Up until now I have been writing bots in Ubot 5, and moving code to ubot 4 after written most code... So with the new Spawn Thread thought would do some testing... And testing not too good There is no designated thread ID, meaning can not control the threads properly Setting thread ID within the thread is not suitable, and some threads will end up with same number (about 1 in 1000, in my testing). Wiki page for the 'Thread Spawn' command is very weak with no real use example. So then thought would test Smart Threading in Ubot 5 and still similar issue... Can anyone show working code for multithreading in Ubot 5.... Feel like I have wasted another day on Ubot 5 Here is my testing script so far... This one is SmartThreads in Ubot 5.... ui drop down("Spawn Total","1,10,100,1000,5000,10000,50000,100000,200000",#spawn_total) ui drop down("Spawn Max","1,10,20,30,40,50,100,150,200,300,400,500",#spawn_max) ui stat monitor("Table Rows",#stats_tableRows) ui stat monitor("Checked (bad/good)","{#var_loopCheckCells} ({#stats_bad}/{#stats_good})") ui button("Save") { SAVE_NORM_TABLE_TO_FILE() stop script } clear table(&DATA) set(#stats_tableRows,$table total rows(&DATA),"Global") set(#my_threadId,0,"Global") if($comparison(#spawn_max,"= Equals",1)) { then { alert("Looping tasks instead of threadding tasks. & Using Global Varibles") loop(#spawn_total) { MAIN_PROCESS(#my_threadId) increment(#my_threadId) } } else { plugin command("Smartthreads.dll", "Thread control normal", "MAIN_PROCESS", #spawn_total, #spawn_max, "No") } } plugin command("Smartthreads.dll", "Smart thread stop") CHECK_BLANK_CELLS() alert("done") stop script define MAIN_PROCESS(#my_threadId) { wait($divide($rand(1,1000),1000)) set table cell(&DATA,#my_threadId,0,#my_threadId) set(#stats_tableRows,$table total rows(&DATA),"Global") wait($divide($rand(1,1000),1000)) } define SAVE_NORM_TABLE_TO_FILE { set(#var_saveTableFile,$plugin function("File Management.dll", "$custom save dialog", "csv", "CSV File", $special folder("Desktop")),"Global") if($comparison($trim(#var_saveTableFile),"= Equals",$nothing)) { then { alert("Failed to save.") stop script } else { save to file(#var_saveTableFile,&DATA) alert("Saved.") plugin command("File Management.dll", "open file", #var_saveTableFile) } } } define CHECK_BLANK_CELLS { set(#var_loopCheckCells,0,"Global") set(#stats_bad,0,"Global") set(#stats_good,0,"Global") loop($table total rows(&DATA)) { set(#var_cellData,$table cell(&DATA,#var_loopCheckCells,0),"Global") if($comparison($trim(#var_cellData),"= Equals",$nothing)) { then { increment(#stats_bad) } else { increment(#stats_good) } } increment(#var_loopCheckCells) } alert("Bad {#stats_bad} Good {#stats_good}") stop script wait($rand(0.5,0.0001)) } I want to get my Multithread Framework for Ubot 5 sorted, and can get back to work creating cool tools Quote Link to post Share on other sites
UBOTEM 18 Posted December 30, 2015 Author Report Share Posted December 30, 2015 Almost the same code on ubot 4 works perfectly without errors! ui drop down("Spawn Total", "1,10,100,1000,5000,10000,50000,100000,200000", #spawn_total) ui drop down("Spawn Max", "1,10,20,30,40,50,100,150,200,300,400,500", #spawn_max) ui stat monitor("Table Rows", #stats_tableRows) ui stat monitor("Checked (bad/good)", "{#var_loopCheckCells} ({#stats_bad}/{#stats_good})") ui button("Save") { SAVE_NORM_TABLE_TO_FILE() stop script } clear table(&DATA) set(#stats_tableRows, $table total rows(&DATA), "Global") if($comparison(#spawn_max, "=", 1)) { then { alert("Looping tasks instead of threadding tasks. & Using Global Varibles") set(#my_threadId, 0, "Global") loop(#spawn_total) { MAIN_PROCESS(#my_threadId) increment(#my_threadId) } } else { plugin command("Smartthreads.dll", "Thread control normal", "MAIN_PROCESS", #spawn_total, #spawn_max, "No") } } plugin command("Smartthreads.dll", "Smart thread stop") CHECK_BLANK_CELLS() alert("done") stop script define MAIN_PROCESS(#my_threadId) { wait($divide($rand(1, 1000), 1000)) set table cell(&DATA, #my_threadId, 0, #my_threadId) set(#stats_tableRows, $table total rows(&DATA), "Global") wait($divide($rand(1, 1000), 1000)) } define SAVE_NORM_TABLE_TO_FILE { set(#var_saveTableFile, $plugin function("File Management.dll", "$custom save dialog", "csv", "CSV File", $special folder("Desktop")), "Global") if($comparison($trim(#var_saveTableFile), "=", $nothing)) { then { alert("Failed to save.") stop script } else { save to file(#var_saveTableFile, &DATA) alert("Saved.") plugin command("File Management.dll", "open file", #var_saveTableFile) } } } define CHECK_BLANK_CELLS { set(#var_loopCheckCells, 0, "Global") set(#stats_bad, 0, "Global") set(#stats_good, 0, "Global") loop($table total rows(&DATA)) { set(#var_cellData, $table cell(&DATA, #var_loopCheckCells, 0), "Global") if($comparison($trim(#var_cellData), "=", $nothing)) { then { increment(#stats_bad) } else { increment(#stats_good) } } increment(#var_loopCheckCells) } alert("Bad {#stats_bad} Good {#stats_good}") stop script wait($rand(0.5, 0.0001)) } Quote Link to post Share on other sites
vemomedia 7 Posted December 30, 2016 Report Share Posted December 30, 2016 funny how i was looking for better info on thread spawn but no one answered my post either, and this post was made a year ago, almost 2 now Quote Link to post Share on other sites
memeuu 12 Posted May 15, 2017 Report Share Posted May 15, 2017 Funny how I spent hours making a multi-threaded bot with ubot5, fixed errors after errors, and it never runs properly. Always crashes and freezes. Use the same code on UBOT4 and it runs like a dream! If you're having trouble with ubot5, give ubot4 a try. Ubot4 still rocks! 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.