local array...

Discussion in 'Questions (Windows Mobile)' started by Byak@, May 19, 2009.

  1. Byak@

    Byak@ Active Member Licensed User

    how i'm understand it is not real,arrays only global?
    i want use strSplit and getcontrols but sub with this operators called by 2 threads.and i have error 'array changed'
  2. agraham

    agraham Expert Licensed User

    :confused:. Example code?
  3. Byak@

    Byak@ Active Member Licensed User

    Public Sub objectexist(name,module)
    Dim gdgtemp(0)
    return ex
    end sub
    sub drawimage(image,params)
    dim gdgtemp(0)
    end sub
    if two threads call this sub at one moment i have error 'array changed'
  4. agraham

    agraham Expert Licensed User

    This is what the RunLocked methods are for.

    When two (or more) threads, including the main thread, call the same Sub then the Sub should be invoked via RunLocked to avoid the Sub being entered twice at the same time by different threads.

    Try something like :

    Thread1.Runlocked2("ModuleName_objectexist", name,module)

    Note that all the threads that invoke this method must RunLock it on the same Thread object, not use their own RunLocked method. The Thread on which RunLocked is invoked is acting as the object that is locked preventing other threads accessing the Sub until RunLocked has returned to the first caller.

    Also note that RunLocked is a normal call and runs on the thread that called it so, as usual, don't touch any GUI elements in a Sub run by RunLocked unless you have invoked RunLocked directly or indirectly from a Thread event or by CallGuiSub in BasicLib.
  5. Byak@

    Byak@ Active Member Licensed User

    big thanks agraham)
    but if runlocked, i can not sleep thread =((( or can?
  6. agraham

    agraham Expert Licensed User

    I don't know why you should think that. RunLocked is just like a call to a Sub unless another thread is running the same Sub in which case the second thread is suspended until RunLocked returns to the first thread, then the second thread is allowed to run. Sleeping a thread is entirely independent of this process.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice