NetTalk Central

Author Topic: Timer procedure from the webserver  (Read 3479 times)

billbarker

  • Newbie
  • *
  • Posts: 30
    • View Profile
    • Email
Timer procedure from the webserver
« on: March 20, 2015, 07:19:53 AM »
Is there any reason why I should not  invoke a new thread from the webserver window, on a timer?

I want to add entries to an email queue during normal processing by users (it seems to take a while to send an email) so I thought I'd just slot the details into a queue, and process this on a timer invoked process, from the main webserver window?


Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Re: Timer procedure from the webserver
« Reply #1 on: March 20, 2015, 12:08:45 PM »
Bill

Great question.  I was contemplating exactly the same approach.  In my case I want to send an email based on actions a user takes on a Form (to change a critical field for example).  The user is not sending the mail but the program logic determines that one is required.  So I was going to add the details to a queue or file and run a process off a Webserver timer to send the mails and mark them (in the file) as 'Sent'.

I do have an unrelated process running off a Timer which periodically creates a CSV file and I guess that unless you can have two Timers that you would just include logic to either perform both actions with the same period or a logic fudge to perform them out of sync.

Haven't coded it yet but will be interested in any advice.

Keith
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Timer procedure from the webserver
« Reply #2 on: March 22, 2015, 02:33:00 PM »
Hi Bill,

the easier approach is to probably just start a new thread in your code to send the email.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Timer procedure from the webserver
« Reply #3 on: March 22, 2015, 09:54:13 PM »
>> Is there any reason why I should not  invoke a new thread from the webserver window, on a timer?

no. You can start new threads from the WebServer window if you like. And indeed _anything_ (and I mean _AnyThing_) with a window (including reports) MUST be on a separate thread. ANY other window opening from the WebServer WILL cause the server to break.

>> Kevin: the easier approach is to probably just start a new thread in your code to send the email.

yes, remember each request is already on it's own thread. You can "use" this thread if you like. To signify to the browser that the reply is complete (and therefore can be displayed to the end user) you do a
p_web.ReplyComplete()
At this point the connection to the browser is ended.
You can now continue to use the thread, send an email or whatever.

Cheers
Bruce

billbarker

  • Newbie
  • *
  • Posts: 30
    • View Profile
    • Email
Re: Timer procedure from the webserver
« Reply #4 on: March 23, 2015, 02:10:46 AM »
Great.. I'll give it a try (just thought I'd better check!)