NetTalk Central

Author Topic: Starting Threads inside the Web Server  (Read 19654 times)

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Starting Threads inside the Web Server
« on: July 11, 2008, 03:03:44 AM »
Hi All,

As you know, each incoming request spawns a new thread to handle the request.

However, you may not know, but this thread typically doesn't have a Window structure, has no ACCEPT loop, and simply runs from start to finish. This matters not, except in the case where you spawn your own thread from this thread.

If you wish to start a thread (to perform some task in the background) then typically you would call something like;

START(MyProc,25000)

Which normally would be sufficient. However because this thread has no ACCEPT loop, a slight variation to the START call is required. Your call to start the thread should look like this;

RESUME(START(MyProc,25000))

This allows the current thread to continue running, as well as giving some time to the newly started thread.

Cheers
Bruce

PS This tip applies on to Clarion 6 and later, RESUME is not in the language in Clarion 5.5.

Robert Iliuta

  • Sr. Member
  • ****
  • Posts: 472
    • View Profile
    • Email
Re: Starting Threads inside the Web Server
« Reply #1 on: July 25, 2014, 12:37:22 AM »
Thank you Bruce for this tip!
Also is there any other way to include web server in a AppFrame window? and this way we can start other windows on separate threads?
Or it's a chance to start web server on a MDI window?

Thank you.
Robert

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Starting Threads inside the Web Server
« Reply #2 on: July 25, 2014, 04:21:47 AM »
Hi Robert,

The tip is specifically for STARTing threads from inside a WebHandler Thread - ie NetWebPages, NetWebBrowses and so on.

Starting a thread from the WebServer window is exactly the same as starting a thread in any windows program.

You could in theory have the webserver in a AppFrame window, but it makes no sense to do that because you would lose the logging and performance monitoring features. You don't need an AppFrame to start new threads, so I think you're on the wrong track here.

Cheers
Bruce