Jump to content
UBot Underground

Multithreading What Is Working - Spawn Thread - Smart Threads Ubot 5 - Ubot 4 -


Recommended Posts

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 :D

Link to post
Share on other sites

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))
}

Link to post
Share on other sites
  • 1 year later...
  • 4 months later...

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!

  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...