Results 1 to 3 of 3

Thread: Console - function to be called at shutdown

  1. #1
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,819
    Blog Entries
    3
    Rep Power
    695

    Console - function to be called at shutdown

    I am thinking about solution for maintaining large amounts of scripts running on servers.

    The problem occurs, when new installation of thinBASIC arrives, and I would like to shut them down before the update.

    Because most of the scripts are console based, I cannot handle this by processing %WM_CLOSE, but would need something similar.

    Now, thinBASIC has TBMain, which is called automagically, so what about new one:
    - TBTerminate

    Would be called, when somebody attempts to kill thinBASIC process.
    It could return a value, indicating whether the shutdown can be performed, or it could also block it.

    Let me know, what do you think...


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    51
    Posts
    8,313
    Blog Entries
    2
    Rep Power
    10
    Ciao Petr,

    not sure what you need, I try to guess something:
    • you want a controlled closing of your script so when something try to close it (by [X] for example), thinBasic intercept it and, if present, will perform TBTerminate function
    • or you want a global command to shut down all scripts under execution
    • or both
    • or something I didn't get


    I understand in such a situation where many scripts are executed, updating thinBasic can be a problem.
    The only solution I see is a kind of "watchdog service" able to "talk" with all running scripts (for example via TCP or UDP) able to tells all script to shut down and later to resume all of them.
    Using UDP it would not be that complex to create it, it is very close to UDP_Notify_Server.tBasic, UDP_Notify_Client.tBasic you can find at \SampleScripts\TcpUdp\

    I'm thinking to some Server script used as coordinator, all clients share a bit of code able to talk to server.
    Every client let the server know that it is alive and what is the script/process/...
    The server collects all those info and have some commands to send to all registered clients to shutdown.

    Do not know, just an idea
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,819
    Blog Entries
    3
    Rep Power
    695
    Hi Eros,

    my apologies for not being clear. The note about "many scripts" was just to give context. All I need is a function, which is executed automatically once somebody presses Ctrl-C or tries to terminate tBasic script with console in other way.
    So BASICally "you want a controlled closing of your script so when something try to close it (by [X] for example), thinBasic intercept it and, if present, will perform TBTerminate function".

    The server idea is great, but I wanted something simple, so I could have scripts like:
    Uses "Console"
    
    Function TBMain()
      Do
        ' -- Monitoring
      Loop
    End Function
    
    Function TBTerminate()
      ' -- Do any task needed before killing script (writing data, ...)
    End Function
    


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

Similar Threads

  1. Megaupload shutdown
    By zak in forum Shout Box Area
    Replies: 2
    Last Post: 15-02-2012, 10:02
  2. Console Box and Console Readline
    By TheOne in forum Console
    Replies: 8
    Last Post: 22-03-2011, 18:32
  3. my first console script :)
    By Lionheart008 in forum Console
    Replies: 2
    Last Post: 18-02-2009, 13:14
  4. console window
    By fravado in forum Shout Box Area
    Replies: 3
    Last Post: 08-04-2008, 15:26

Posting Permissions

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