gambas-source-code/app/examples/Misc/Multiprocessing/.src/FMain.class
Martin Fischer 3180d51c8f Adds Multiprocessing example project
[EXAMPLES]
* NEW: misc/Multiprocessing
2023-09-02 20:01:29 +02:00

26 lines
745 B
Text

' Gambas class file
Private primesTask As Task
Public Procedure btnStart_Click()
' background process ist started with construction of Task instance
primesTask = New CalcPrimesTask(valMaxPrimes.Value) As "taskEvents"
btnStart.Enabled = False
valResult.Value = Null
calcSpinner.Show
calcSpinner.Start
End
Public Procedure taskEvents_Kill()
' the background process has terminated -> fetch the result value
' Note that task.Value might raise an error if the task itself raised an error
valResult.Value = primesTask.Value
Finally
btnStart.Enabled = True
calcSpinner.Stop
calcSpinner.Hide
Catch
Message.Error("Something went wrong during background calculation: " & Error.Text)
End