Scheduling Web Api method to run on set intervals

后端 未结 4 2418
夕颜
夕颜 2021-02-20 00:58

In my current project there is a need to schedule a method to run at set intervals e.g. once a week, and currently this is done via a windows service creating an HttpClient and

4条回答
  •  春和景丽
    2021-02-20 01:20

    I'm not saying this is the best approach but it worked for me and it was pretty easy.

    Our WebApi was already in place and I needed a quick solution to call the API once an hour. I used node.js and wrote a few lines of code that utilized the moment.js library. There's a timer/countdown feature available. I set it to fire every hour and make the call to our API. Had it working on IIS. It was at my previous employer otherwise I would post the actual code.

    It was easy and it worked. Hope it helps someone. node.js + moment.js library.

提交回复
热议问题