Announcement

Collapse
No announcement yet.

Best way to call a POP3 server at an interval?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Best way to call a POP3 server at an interval?

    I've written a POP3 checker and wonder what is the best way to check for email every so often.
    Is it better to use a timer, a thread, or just call the program at an interval from another program?

    Calling from another program actually has some advantage as it can also be used to launch/monitor multiple programs.
    Using a thread is easy, but may not be the best way.
    Last edited by Mike Doty; 24 Apr 2009, 10:48 AM. Reason: may be s/b may not be

  • #2
    Depends if you want your program running all the time and when/how it's supposed to tell you, "You've got mail to pick up."

    If you don't need the program running all the time,Windows Scheduler works just fine.

    If you do need/Want the program running all the time, a simple timer sounds promising.

    If the program is running all the time, using a timer, has a persistent UI (tray?) and this this 'checking" takes more than one-tenth second, then you at least want to think about performing that check in a separate thread of execution.... and this demo sounds like it might be useful for that purpose:

    GUI + Worker Thread + Abort Demo 11-24-07

    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      How do you call Windows scheduler to call a program every so often?
      http://en.wikipedia.org/wiki/Task_Scheduler

      Create a job file. This looks promising.
      Thank you, Michael.
      Last edited by Mike Doty; 24 Apr 2009, 11:09 AM.

      Comment


      • #4
        I know Scheduler has a COM-based API, but I don't know if anyone has tried using it.

        I was thinking to just hit Start/Programs/Accessories/System Tools/Schduled Tasks and defining one.

        NOTE: if you want something to run every 'X' minutes, on specific days, you have to start by defining the task to Windows Scheduler as a "weekly" task. (I was not in the room when that design decision was made.)

        Me and one of my clients - also a technical/programmer type - together wasted about an hour trying to set this up "intuitively" using the provided screens, prompts and help files, only succeeding when one of us hit "weekly" by mistake and lo and behold the screen we wanted came up!
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          It sure could be used for a lot of things (not that I don't like programming.)
          I'll try to see if I can find examples on the net and in the forum.
          I'm looking at some VB stuff, now.

          Comment


          • #6
            I was driven to try Scheduler by client requirements... we needed something which could run every 15 minutes, Monday thru Friday, from 7:00 AM to 10:00 PM.

            I could have written it myself, but it would have cost my client mucho dinero.

            However, I knew Scheduler existed, and I knew that there are commercial products to do this (eg, Ground Control, a referral I got here many years ago), and I figured why not look for an existing product to meet our needs? Even if we could not have gotten Windows Scheduler to work, fifty or sixty bucks for an off-the-shelf solution had to be a better decision than writing something from scratch.


            MCM
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Why would it be expensive for about 10 lines of code.
              Mike yes a timer is ideal, as I said in the other post my code is in a DLL and called from another program( VB) every 2 minutes from 8am to 8pm. If the mail server is very slow then you might consider a thread and if it is very slow then and you are calling very regularly obviously a flag to ensure you don't call it twice without a return from the functions or as I do, turn the timer off until there is a return from the functions, then restart it.

              Comment


              • #8
                >Why would it be expensive for about 10 lines of code.

                Oh, really?

                Perhaps without any error handling, requires recode/recompile to change anything, no auditing or control it could be done in ten lines of code.

                Unfortunately, in the Real World you need these other things, as my clients' customers ofter have alternate vendors they could use.

                FWIW, if you have an automobile and ocassionally go to the parts counter at Napa, Autozone, Carquest or Summit Racing (Atech) and have to order a part (for my 1996 Mercury nothing is in stock anymore), depending on the part you order you are using what IS installed at this client, making YOU one of my users.

                When you need that part, aren't you glad I didn't just hack this thing together in, say, ten lines of code?


                MCM
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  While automobile repair parts are hardly life-and-death matters, this got me thinking.

                  I wonder how much "execution speed" or "development time" we'd all be willing to trade for more/better error handing, audit control, editing, and ease of restart/re-do if we forced ourselves to think beyond the confines of the IT office to the ultimate end-users of our software?

                  I did some work for a manufacturer of medical devices two years ago. Same kind of thing I do a lot of: customer sends orders to my client electronically, I have to get them into my client's ERP system so they can be picked, shipped and invoiced.

                  This particular client took orders from hospitals for operating room supplies... for scheduled surgeries.

                  Just imagine how you'd feel if the doctor told you, "We'll have to postpone your child's procedure because of a software screwup by one of our supplies vendors."

                  Or maybe you've been bugged by a doctor or collection agency because your health insurance company failed to pay a bill on time ... because of a software screwup by the payer's software developer?


                  How about rescheduling a week's worth of production (about 30 people) because a vendor could not send a proper advance ship notice for the steel he shipped yesterday... and because you don't have enough to start a production run unless you know that steel is going to arrive on Tuesday, you have to postpone the production run (not to mention upset your customers who were counting on you making those items next week)?

                  Whether you are an outside consultant/contractor or an employee, you'll create better software if you think about what kind of bad things can happen to you, your family or friends if your software fails.
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    Originally posted by Michael Mattias View Post
                    >Why would it be expensive for about 10 lines of code.

                    Oh, really?

                    Perhaps without any error handling, requires recode/recompile to change anything, no auditing or control it could be done in ten lines of code.

                    Unfortunately, in the Real World you need these other things, as my clients' customers ofter have alternate vendors they could use.

                    FWIW, if you have an automobile and ocassionally go to the parts counter at Napa, Autozone, Carquest or Summit Racing (Atech) and have to order a part (for my 1996 Mercury nothing is in stock anymore), depending on the part you order you are using what IS installed at this client, making YOU one of my users.

                    When you need that part, aren't you glad I didn't just hack this thing together in, say, ten lines of code?


                    MCM
                    What does any of that have to do with the question of "how to call at a regular interval" I assure you my entire program is not a "hack" and is used by a multi million dollar coporation. Yes it has audit trails, automatically sends email back to the customers of errors, rejects spam and viruses. As it is in a different country from me I can click on a button on my computer and it will send me the last 64K bytes of the audit trail. All again has nothing to do with the few lines of code that control the frequency of checking for mail. Surprise, you are not the only professional programmer in the world.

                    Comment


                    • #11
                      MCM
                      Seems while I was typing my reply you posted more pontifical cr*p which has nothing to do with the question. I do not "hack" commercial code.
                      John
                      PS I have been President of a Multi National, multi million dollar life saving medical company in the USA so am well aware of the requirements and the legal implications of dealing with the FDA so don't need any advice from you on the subject

                      Comment


                      • #12
                        All again has nothing to do with the few lines of code that control the frequency of checking for mail
                        As you point out youself, the 'ten lines' is ONLY to control the frequency. I inferred you were suggesting the entire program could be done in 'ten lines.'

                        Oh, well, at least I got to excercise Ye Olde Braine Celles.
                        Michael Mattias
                        Tal Systems (retired)
                        Port Washington WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #13
                          Originally posted by Michael Mattias View Post
                          Ye Olde Braine Celles.
                          Defined in some (non-programming) dictionaries as "n. - Bloviated balderdash". adj. "imaginary implied self-important grandiosity"


                          ==================================
                          Admiration, n.:
                          A polite recognition of another's
                          resemblance to ourselves.
                          Ambrose Bierce (1842-1914)
                          ==================================
                          Last edited by Gösta H. Lovgren-2; 25 Apr 2009, 11:12 AM. Reason: {sorry, I just couldn't resist}
                          It's a pretty day. I hope you enjoy it.

                          Gösta

                          JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                          LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                          Comment


                          • #14
                            >Defined in some (non-programming) dictionaries ....

                            I think you forgot "condescending egoism."

                            But you also forgot, it's my opinion; and AFIAK as long as I stay within the sponsor's rules I am welcome to share it here.

                            You, of course, are free to agree, disagree or ignore it.

                            In the case at hand, asking Mr. Petty to show us just what ten lines could accomplish the task was likely a fool's errand, since he has yet to grace us with even one demo in the source code forum.

                            Call me old-fashioned, but seems to me the only valid 'coin of the realm' in the field of programming is one's code.
                            Michael Mattias
                            Tal Systems (retired)
                            Port Washington WI USA
                            [email protected]
                            http://www.talsystems.com

                            Comment


                            • #15
                              Originally posted by Michael Mattias View Post
                              >Defined in some (non-programming) dictionaries ....

                              I think you forgot "condescending egoism."
                              Thank you. I will update the definitions accordingly.
                              But you also forgot, it's my opinion; and AFIAK as long as I stay within the sponsor's rules I am welcome to share it here.
                              I am unaware of any implication otherwise. A reader's inference is, of course, not in my control. Egotists often feel others are out to "get them".
                              You, of course, are free to agree, disagree or ignore it.
                              Thank you for your permission.
                              In the case at hand, asking Mr. Petty to show us just what ten lines could accomplish the task was likely a fool's errand, since he has yet to grace us with even one demo in the source code forum.

                              Call me old-fashioned, but seems to me the only valid 'coin of the realm' in the field of programming is one's code.
                              Ah yes, the old "Put up or Shut Up" ploy. Well played, my man. I am somewhat surprised though you would call yourself a likely fool, however (in?)appropriate it may be.

                              ================================
                              Anger is never without a reason
                              but seldom a good one.
                              Ben Franklin
                              ================================
                              It's a pretty day. I hope you enjoy it.

                              Gösta

                              JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                              LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                              Comment


                              • #16
                                Not to , but I think providing a little "business context" in the form of a narrative sometimes - no, make that often - serves the developer as well or even better than does twenty or thirty sterile lines of source code.

                                However, I will agree such narrative is probably of far more interest to "developers" and "consultants" than to "contractors" ... or those who are now "contractors" but wish to become "developers" or "consultants."


                                MCM
                                Michael Mattias
                                Tal Systems (retired)
                                Port Washington WI USA
                                [email protected]
                                http://www.talsystems.com

                                Comment


                                • #17
                                  That is the biggest load of codswalop I have read from you yet Michael.. PB is a language for programmers, its speed is partly based on the concept that the user is proficient enough to write code that only does error checking when needed.
                                  What do you want? Some honorary degree from a university on programming? You won’t get it you have posted too much erroneous information.
                                  I post on the basis that there are better more experienced programmers on this site than me, so only offer a few lines of sterile code if I think it might help, and on occasions it is wrong or not helpful.
                                  I have found this site very useful over the years and in my own small way tried to repay. There is no way I have the time to make 22,000 posts so please leave me out of any of your discussions of what a contributor should do.

                                  Comment


                                  • #18
                                    >That is the biggest load of codswalop I have read from you yet Michael

                                    Hmm... I guess that's not "total agreement. "

                                    I'll put you down for "undecided."
                                    Michael Mattias
                                    Tal Systems (retired)
                                    Port Washington WI USA
                                    [email protected]
                                    http://www.talsystems.com

                                    Comment


                                    • #19
                                      OK?

                                      Comment

                                      Working...
                                      X