Results 1 to 11 of 11

Thread: Allow only one program running at specified time

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    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,

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  2. #2
    Addicted Member
    Join Date
    Sep 2009
    Location
    The Netherlands
    Posts
    148

    Post 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

  3. #3
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    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 &#191;
    VB.NET MVP 2008 - Present

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    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,

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  5. #5
    Addicted Member
    Join Date
    Sep 2009
    Location
    The Netherlands
    Posts
    148

    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 ;-)

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Re: Allow only one program running at specified time

    thx Hakka

    that's not working, the currently running program doesn't freeze...

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  7. #7
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    Re: Allow only one program running at specified time

    Why not try the SuspendThread API &#191;
    VB.NET MVP 2008 - Present

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Re: Allow only one program running at specified time

    thx Hannes

    any example?

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  9. #9
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    Re: Allow only one program running at specified time

    VB.NET MVP 2008 - Present

  10. #10
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: Allow only one program running at specified time

    It's possible by raising the priority of a process to Realtime:

    vb.net Code:
    1. Dim prc As Process = Process.GetCurrentProcess
    2. 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.

  11. #11

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width