In the following example, if arriving at "dealer reminded", will this end the whole process? Since the branch is triggered by a non-interrupting event, we could also arrive at "order confirmed".
I hope it works the way that both end events must be reached (assuming "answer a bit late" has been triggered), but in case of the interrupting event "answer overdue" I guess "order not deliverable" will terminate the whole process. Is this correct?
End events only end their respective branch. They "eat" the token, nothing else.
There is a different element that deletes all tokens of its scope, therefore effectively ending it: the "terminate" end event.
So no, "order not deliverable" will not terminate the process and a token at "remind dealer" will remain there.
The BPMN spec says (on p. 246) that "All the tokens that were generated within the Process MUST be consumed by an End Event before the Process has been completed". This means that the process ends when all parallel paths have completed, implying that both a "Dealer reminded" and an "Order confirmed" (or, alternatively, an "Order not available") end event must occur for completing a process according to your model.
Related
I am working on a VB.NET Windows Forms application where the user is supposed to be able to determine how many processes the application is allowed to launch at a time.
My current method mostly works but I've noticed that occasionally the application goes over the set amount. I use two global variables for this, _ConcurrentRuns which is 0 at the start of the application, and _MaxConcurrentRuns which is set by the user.
Private _sync As new Object()
' This is called Synchronously
Private Function RunModel() As Boolean
If CancelExectuion Then Return CancelCleanup()
Do While True
SyncLock _sync
If _ConcurrentRuns < _MaxConcurrentRuns Then
Interlocked.Increment(_ConcurrentRuns)
Exit Do
End If
End SyncLock
Threading.Thread.Sleep(50)
Loop
'This is what will launch an individual process and close it when finished
ret = RunApplication(arg)
' The process has been closed so we decrement the concurrent runs
Interlocked.Decrement(_ConcurrentRuns)
Return ret
End Function
The goal is to let only one thread exit the while loop at a time, I'm not able to catch it in the debug mode however in the task manager it will occasionally go 1-3 processes over what it's supposed to use. This makes me assume that somehow multiple threads are getting inside the synclock somehow, but I have no clue how that could be happening.
I will be very grateful for any and all help that can be provided, thanks for taking the time to read my question.
So it appears that my solution works for this, I don't want to delete this question because it might be helpful to somebody else in the future.
Answer: Use better process monitoring software / set priority to high in task manager.
I'm trying to provide on the save button a validation error saying a certain field can't be left blank.
I'm honestly not sure what to try.
If txtGEMFeeWBS.Text = "" Or lblGEMFeeWBS.Text = "" Then
MsgBox("Error Gem Fee WBS Code must be provided before you can save")
End If
Save_Validation()
If blnValidation = True Then
If Me.lblInvoiceShipmentID.Text = "" Then
Save(1)
Else
SaveAllKitUnits()
Save(2)
End If
End If
After where the message box is thrown I want to close out and not hit save data information
I'm not sure about having understood the question but...
It depends on a lot of things. Do you want to completely close the program? Are you inside a method?, etc...
If you want to close the entire program (I don't think so) just try
Application.Exit()
If you are on a method you can just use the instruction return nothing
And in other cases use the GoTo: Anywhere on the code (almost
anywhere) you can put SampleGoToLine: (don't forget the ':')
and then call the instruction GoTo SampleGoToLine anywhere you
want or, in your case, after showing the messagebox.
(The name SampleGoToLine is invented, you can put any not reserved VB keyword)
Finally what I would personally do is to reestructure the code. Maybe split validation and save into two different methods or something similar so you can always control what method do you go to depending on certain conditions. (With a simple if-else structure)
Can I use multiple End event in One Process?
if yes, How to declare which End Event is Main End Event?
To Clarify the Question, let me demonstrate it.
We have main process that has a sub process. There is a inclusive or parallel gateway inside sub process that branch out into multiple paths. All of the paths leads to None End event.
Which End event is triggered in order to continue main process?
for example in attached image Example , I want Main Process to be continued and run Task1, whenever End Event B be triggered (None of the both other End events, A or C)
I would add an exlusive gateway after your subprocess that is asking the question "What was the result of the subprocess?". But I think you could also simplify the model:
Since the activities related to A and C are always executed but have no significance for the rest of the process, I would do them separattely from B and then check if B was the case or not. This basically translates to "We have to do A and C but we really only care about B".
Here are both versions as I would have done them.
I am using Point Grey's FlyCapture API to drive some cameras.
In a public class, I implemented all the starting and initializing code ; in the following _cam refers to a ManagedGigECamera.
Because I have 16 cameras, I want the code to be as fast as possible, so I wanted to use tasks.
Here is the code I use:
_cam.StartCapture(AddressOf OnImageGrabbed)
.../...
Public Sub OnImageGrabbed(ByVal raw_image As ManagedImage)
Dim t As Task = Task.Run(Sub()
'save image to disk or whatever
End Sub)
t.Wait()
End Sub
The above gives -sort of- satisfaction. By viewing image timestamps, I can see that some images are saved seconds after they are grabbed, and even some images are skipped altogether...
I wanted to make sure each call to OnImageGrabbed would start a new task, and tried the following, but it crashes right away with 'object not set to an instance of an object' (can't really debug, the code is running on a remote machine)
_cam.StartCapture(AddressOf OnImageGrabbed)
.../...
Public Async Sub OnImageGrabbed(ByVal raw_image As ManagedImage)
Await Task.Run(Sub()
'save image to disk or whatever
End Sub)
End Sub
All in all, my questions are:
how can I run an event handler asynchronously ?
why, using the first code, do I get (what appears to be) random delays between each call
to OnImageGrabbed ? I mean the differences in time between image timestamps is never the same, and tend to increase on the long run (first few images are almost synchronized, but after 1 minute or so, each image is separated by more and more time). Memory leak ? GC ?
Thanks in advance for any hint !
EDIT:
In the end I changed the way the system works: I fire a software trigger on each camera using a timer, and each trigger is fired 'in parallel':
Parallel.ForEach(Of ListOfCameras)(SingleCamera,
Sub(aCamera, loopstate, num)
aCamera.FireTrigger()
End Sub)
Starting a task and then immediately blocking on it (via Wait) nets you nothing. You may as well just run the saving-image code directly.
The second example is actually asynchronous. You're probably getting an exception because the ManagedImage argument or one of its child objects is being disposed. Remember that the code raising the event has no idea that your code is asynchronous; it's up to you to copy out what you need from the event arguments if you're going to use it asynchronously.
I'm trying to figure why my form freezes up when executing some code. I also can't minimize or move the form. Is it because of the WaitForExit being used in the process?
The below code is tied to a button click.
If Checkbox1.checked = True Then
Call Test()
End If
If Checkbox2.checked = True Then
Goto NextStep
Else
Goto StopProcessing
End If
Here is the test sub I'm calling. Calls an exe with an optional argument.
Using psinfo As New Process
psinfo.StartInfo.FileName = "C:\Temp\Test.exe "
psinfo.StartInfo.Arguments = Arg1
psinfo.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
psinfo.Start()
psinfo.WaitForExit()
End Using
The WaitForExit was added (so I thought) to not process the next statement (next statement being the If statement for Checkbox2) until the process was complete. Is this not the case?
The WaitForExit was added (so I thought) to not process the next statement (next statement being the If statement for Checkbox2) until the process was complete.
When you call WaitForExit, it will block until the process (Test.exe) completes.
Since you're running this on the user interface thread, it will cause your form to "freeze" until the process completes fully.
If you need this to not occur, you would need to wait on a background thread. You could, potentially, move this code into a BackgroundWorker and use it to synchronize with your main window - but you will need to handle "waiting" for the process to finish in a different manner (ie: disable your UI up front, run the process, re-enable when complete).
Note that, with the Process class, another alternative would be to add EnableRaisingEvents on the process, then adding a handler to Process.Exited. This will let you not WaitForExit(), but instead get notified via an event when the process completes.