Jump to content

is that multithread? Are there any disadvantages In this method?


Guest
 Share

Recommended Posts

I think I found some method to run more then one loop at the same time and also use Sleap(1000) Without slowing down these loops:
 
HotKeySet("{ESC}","Exit1")

AdlibRegister("Loop1",100) ; loop that sleap 100 Milliseconds
AdlibRegister("Loop2",100) ; loop that sleap 100 Milliseconds

ConsoleWrite("      Sleep 1 <---------------------------------------------------------------------------" & @CRLF)
Sleep(1000)
ConsoleWrite("      Sleep 2 <---------------------------------------------------------------------------" & @CRLF)
Sleep(1000)
ConsoleWrite("      Sleep 3 <---------------------------------------------------------------------------" & @CRLF)
Sleep(1000)
ConsoleWrite("      Sleep 4 <---------------------------------------------------------------------------" & @CRLF)

For $a = 5 To 15
    Sleep(1000)
    ConsoleWrite("      Sleep "&$a&" <---------------------------------------------------------------------------" & @CRLF)
Next

While 1
    Sleep(1000) ; I am sleaping 1000 Milliseconds!!
WEnd

Func Loop1()
    ToolTip("Loop1") ; And at the same time I sleaping 100 Milliseconds
EndFunc   ;==>Example


Func Loop2()
    ConsoleWrite("Loop2"&@CRLF) ; And at the same time I sleaping 100 Milliseconds
EndFunc   ;==>Example


Func Exit1()
    Exit
EndFunc

I do not know if it is real multithread but I think it does not really matter because it does what multithread does

according to how it works..
 
It is still very Good thing to know..
 
But anyway it's still interesting to me if this is real multithread.
It's a way to run more then one loop at the same time with no effect from Sleap outside the loop.
Each loop is not affected by Sleap() outside the loop and this is another major advantage ..
 
But these loops are written In a different way (read more >here)

Are there any disadvantages In this method?

Edited by Guest
Link to comment
Share on other sites

  • Developers

Your example has nothing to do with mulitythreading.

The regular process is simply interupted for the defined adlib funcs and will continue when they are done.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

It is certainly not multi threading, and no loops are running at the same time.

I was just asking a question ..

i know that these are not loops but they work like loops so i call them loops.

loop is some code that run again and again every period of time.

If you judge it by the result,

in this code:

While 1
    ConsoleWrite("code" & @CRLF)
    Sleep(1000) ; I am sleaping 1000 Milliseconds!!
WEnd

and in this code:

AdlibRegister("Loop",1000)
Func Loop()
    ConsoleWrite("code" & @CRLF)
EndFunc  

While 1
    Sleep(10)
WEnd

the result is code that run again and again every 1 Second.

So If I look at the result then i can call it a loop..

And I did not say that it is multi threading.. I'm just asking if this is really multi threading

Edited by Guest
Link to comment
Share on other sites

  • Developers

I was just asking a question ..

And I did not say that it is multi threading.. I'm just asking if this is really multi threading

And the answer is no. ;)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

It's not multithreaded, it's not even pretend multithreading. It's just pausing one function to run another, then going back to the first function.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

It's not multithreaded, it's not even pretend multithreading. It's just pausing one function to run another, then going back to the first function.

 
Ok, I am not surprised that this is the answer.

 

 
I think that this kind of loops is much better than Regular loop.

I see a lot of potential in this type of loop.

I know you may not call it a loop and you may have good reasons.

But from a human perspective, it seems to me like a loop

.
Edited by Guest
Link to comment
Share on other sites

  • Developers

Call it what you like, but both of your example code snippets serve a different purpose.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

My super loop is the boss of your loop.

Loop()

Func Loop()
    Sleep(500)
    ConsoleWrite("Tra la" & @LF)
    Poop()
EndFunc

Func Poop()
    Sleep(500)
    ConsoleWrite("di da" & @LF)
    Loop()
EndFunc

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Then the user will be asking what does stack overflow mean?

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

 

My super loop is the boss of your loop.

Loop()

Func Loop()
    Sleep(500)
    ConsoleWrite("Tra la" & @LF)
    Poop()
EndFunc

Func Poop()
    Sleep(500)
    ConsoleWrite("di da" & @LF)
    Loop()
EndFunc

lol, you made a loop with two functions.

It's an interesting subject.

It does not "loop" and it is "overflow" ?

 
If so what are the differences between "loop" and "overflow"?  There is no difference right?
it looks the same thing
 
Maybe I'm asking stupid questions..
Edited by Guest
Link to comment
Share on other sites

Maybe try it before posting.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

 

lol, you made a loop with two functions.

It's an interesting subject.

It does not "loop" and it is "overflow" ?

 
If so what are the differences between "loop" and "overflow"?  There is no difference right?
it looks the same thing
 
Maybe I'm asking stupid questions..

 

Guinness is saying unrestricted recursion will eventually cause stack overflow.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Guinness is saying unrestricted recursion will eventually cause stack overflow.

Oh, I see.

In fact I've seen in the past this form of coding. But I did not think that it will cause a fatal error in stress case...

If you would post this example:

Loop()

Func Loop()
    Poop()
EndFunc

Func Poop()
    Loop()
EndFunc

then i know what you're talking about more earlier

 

I have an important question(this is important for me) and it is also nice game :muttley:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


Test()

Func Test()
    Local $Form1 , $Button1 , $nMsg
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Game Click", 250, 85, 233, 150)
    $Button1 = GUICtrlCreateButton("Click", 72, 24, 97, 41)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button1
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete($Form1)
    Test()
EndFunc

How many times you need to click on the "click" until  you see the error:

Recursion level has been exceeded - AutoIt will quit to prevent stack overflow.:

EDIT:

I tried many times to press the button "Click" and i didn't got the error..

So that bug that i found is almost unreachable

Edited by Guest
Link to comment
Share on other sites

Recursion level is explained in the helpfile somewhere. If I recall AutoIt handles it internally so I'm not so sure that this kind of recursion can cause stack overflow in AutoIt really.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Recursion level is explained in the helpfile somewhere. If I recall AutoIt handles it internally so I'm not so sure that this kind of recursion can cause stack overflow in AutoIt really.

Actually yes If you click on the button more then 3899 times.

I cheated the game..

I tested it with the codes:

Global $a = 0
Test()


Func Test()
    $a += 1
    ConsoleWrite($a & @CRLF)
    Test()
EndFunc

and

Func Test()
    $a += 1
    Local $Form1 , $Button1 , $nMsg
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Game Click", 250, 85, 233, 150)
    $Button1 = GUICtrlCreateButton("Click", 72, 24, 97, 41)
;~     GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    GUIDelete($Form1)
    ConsoleWrite($a & @CRLF)
    Test()
EndFunc

In both cases I get the same number

Edited by Guest
Link to comment
Share on other sites

look here:

 

Maximum number of times the Call() function can recurse to itself.:      3900 limit for x64 and 1900 limit for x86

That value changes from time to time.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...