Introduction
There are cases where you want to be sure that STARLIMS Manager Service does not create a new process until the previous one is done or finalized.
How is done
The following code creates a Mutex (*) called "STARLIMS__ArchivingJob" and does not allow the SRV to create a new one until the previous process with same name is finalized.
/*make sure that is only one process for archiving;
:DECLARE mutex, createdNew;
createdNew := LimsNetCast(.F., "ByRef");
:TRY;
mutex := LimsNetConnect("", "System.Threading.Mutex", {.F., "STARLIMS__ArchivingJob", createdNew});
createdNew := createdNew:Value;
:CATCH;
createdNew := .F.;
:ENDTRY;
:IF createdNew;
Usrmes("Started 'sta.srv'",Time());
ExecFunction("DataArchiving.ArchiveEngine.DoWork", {"BATCHES", "CRT", "STA"});
Usrmes("End 'sta.srv'",Time());
:ENDIF;
LWait(10 * 60);
mutex:Close();(*)Mutex: Short for mutual exclusion object. In computer programming, a mutex is a program object that allows multiple program threads to share the same resource, such as file access, but not simultaneously. When a program is started, a mutex is created with a unique name. After this stage, any thread that needs the resource must lock the mutex from other threads while it is using the resource. The mutex is set to unlock when the data is no longer needed or the routine is finished.
Code Courtesy of STARLIMS R&D Department
Comments
0 comments
Article is closed for comments.