|
-
Jan 21st, 2010, 02:10 AM
#1
Thread Starter
Fanatic Member
Allow only one program running at specified time
hi all,
we have this situation, we need to 'force' user to do stock opname at specified time, so when the time has arrived..the stock opname program will run while their current running is 'freeze' until the opname is done..
any insight about it?
not sure where to start..
thanks,
-
Jan 21st, 2010, 02:37 AM
#2
Addicted Member
Re: Allow only one program running at specified time
Hi,
I was intrigued by your question, so I started to look around.
Found some code about comparing time and adjusted it a bit:
Code:
Dim updateTimeMinimum As String = DateTime.Parse("8:30 AM").ToString("t")
Dim t2 As String = DateTime.Now.ToString("t")
Dim updateTimeMaximum As String = DateTime.Parse("8:35 AM").ToString("t")
If t2 > updateTimeMinimum Then
If t2 < updateTimeMaximum Then
MsgBox("going for update")
End If
End If
there's problably a better or cleaner way, but found it working, hope it helps.
succes!
Paul
-
Jan 21st, 2010, 02:42 AM
#3
Re: Allow only one program running at specified time
There will have to be some sort of service ( not necessarily a Service in .NET par se ), that runs in the background. When the specified time arrives, it launches whichever program you want to. Only question is, will it always be at the same time, or will the times frequency change ¿
VB.NET MVP 2008 - Present
-
Jan 21st, 2010, 02:52 AM
#4
Thread Starter
Fanatic Member
Re: Allow only one program running at specified time
thx Hakka, but that's not what i mean..
i just want to make other windows freeze and only running one program (stock opname program)..wait until the opname finish then unfreeze other windows
thx Hannes
Only question is, will it always be at the same time, or will the times frequency change -> for this i'm thinking to using windows Task Scheduler to do it..
my intention is to freeze currently running program and popup stock opname program..
any insight?
thanks,
-
Jan 21st, 2010, 03:01 AM
#5
Addicted Member
Re: Allow only one program running at specified time
Instead of the msgBox (which was an example) you can add
Code:
Dim myProcess As Process = System.Diagnostics.Process.Start("updateProgram.exe")
myProcess.WaitForExit()
which will run the updateprogram and freezes the other until the updateprogram ends.
That's about as far as my knowlegde goes rigth now ;-)
-
Jan 21st, 2010, 03:23 AM
#6
Thread Starter
Fanatic Member
Re: Allow only one program running at specified time
thx Hakka
that's not working, the currently running program doesn't freeze...
-
Jan 21st, 2010, 03:41 AM
#7
Re: Allow only one program running at specified time
Why not try the SuspendThread API ¿
VB.NET MVP 2008 - Present
-
Jan 21st, 2010, 04:12 AM
#8
Thread Starter
Fanatic Member
Re: Allow only one program running at specified time
-
Jan 21st, 2010, 04:58 AM
#9
Re: Allow only one program running at specified time
VB.NET MVP 2008 - Present
-
Jan 21st, 2010, 05:28 AM
#10
Re: Allow only one program running at specified time
It's possible by raising the priority of a process to Realtime:
vb.net Code:
Dim prc As Process = Process.GetCurrentProcess
prc.PriorityClass = ProcessPriorityClass.RealTime
WARNING!
If anything goes wrong the system might not return to its normal state after this.
Always return the priority class to normal after the task is completed.
The system will appear hanged during the execution.
Use with extreme caution! Save your data before testing.
-
Jan 21st, 2010, 05:29 AM
#11
Re: Allow only one program running at specified time
.double post, sorry. Please delete this post.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|