Is there a function that allows you to find out the names of the functions running for execution?
Is there a function that allows you to find out the names of the functions running for execution? I have such a problem in my system. When you do everything properly, everything works fine. But when you run the wrong function for execution, it can give an error. Before starting the function, I would check whether the functions that are allowed are already running. And if some others are running, then the function would not be executed. Then there would be fewer such mistakes. In general, the problem is that the system often issues errors restoring the environment after multiple launches of various modes. I don't know how to cope with these, how to solve this problem
Is there a function that allows you to find out the names of the functions running for execution?
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: Is there a function that allows you to find out the names of the functions running for execution?
Hello Eugene
No, there is not.
Below some code you can try.
No, there is not.
Below some code you can try.
Code: Select all
CLASS IsFunctionRunning
CLASS VAR aFunctions
CLASS METHOD InitClass
CLASS METHOD IsRunning
CLASS METHOD StartFunction
CLASS METHOD StopFunction
ENDCLASS
CLASS METHOD IsFunctionRunning:InitClass()
::aFunctions := {}
Return
SYNC CLASS METHOD IsFunctionRunning:IsRunning(cFunction)
Return Ascan(::aFunctions,{|a|a[1] == cFunction) > 0
SYNC CLASS METHOD IsFunctionRunning:StartFunction(cFunction)
LOCAL lStartOk := .F.
If !::IsRunning(cFunction)
Aadd(::aFunctions,{cFunction,ThreadId()})
lStartOk := .T.
Endif
Return lStartOk
SYNC CLASS METHOD IsFunctionRunning:StopFunction(cFunction)
LOCAL lStopOk := .F.
LOCAL nPos := Ascan(::aFunctions,{|a|a[1] == cFunction)
If nPos > 0 .and. ::aFunctions[nPos,2] = ThreadId()
Aremove(::aFunctions,nPos]
lStopOk := .T.
Endif
Return lStopOk
Function MyFunction()
If IsFunctionRunning():StartFunction("MyFunction")
//
// This is the only run
//
Your code here
//
// We are done
//
IsFunctionRunning():StopFunction("MyFunction")
Else
MsgBox("Function already running")
Endif
Return
Regards,
Jack Duijf
Jack Duijf
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact: