Hi,
Using the code from this post : http://discuss.visual-prolog.com/viewto ... ight=mutex, the following message is displaying (when a second instance of my application is started tu run).
Question : is it possible to replace this message with my own "beautiful" vpiCommonDialogs::note() ?
-
- VIP Member
- Posts: 204
- Joined: 16 Oct 2001 23:01
About Preventing two instances of a program to run simultaneously
You do not have the required permissions to view the files attached to this post.
Last edited by Tonton Luc on 10 Feb 2016 9:22, edited 1 time in total.
-
- VIP Member
- Posts: 57
- Joined: 11 Jul 2002 23:01
Hello Tonton,
I use this code for years without problems.
I do not need a note but leaving out fail should do the job
Kind regards
Ben
I use this code for years without problems.
I do not need a note but leaving out fail should do the job
Code: Select all
constants
error_already_exists = 183. % From MSDN
class facts
okToRunMutex : mutex := erroneous.
taskwindow : taskwindow := erroneous.
class predicates
okToRun : () determ.
clauses
okToRun() :-
try
okToRunMutex := mutex::createNamed("Gregorius"),
not(multiThread_native::wait_timeout = okToRunMutex:wait(1))
catch TraceId do
LastError = exception::getLastError(),
if LastError = error_already_exists
then
vpiCommonDialogs::note("Gregorius is al gestart"),
fail
% Description = common_exception::getLastErrorDescription(LastError),
% vpiCommonDialogs::note(tostring(LastError),Description)
else
common_exception::continue_unknown(TraceId, classInfo, predicate_name())
end if
end try.
clauses
get_taskwindow() = taskwindow.
clauses
run():-
if okToRun() then
TaskWindow = taskWindow::new(),
taskwindow := Taskwindow,
TaskWindow:show()
end if.
Ben
-
- VIP Member
- Posts: 204
- Joined: 16 Oct 2001 23:01