Base solution for your next web application
Open Closed

Change PeriodicBackgroundWorkerBase Period #3532


User avatar
0
ivanosw1 created

Hi, Is possible to change the Period of a PeriodicBackgroundWorkerBase after it has been initilized ? I would like to change it during time reading the value from database ( eg. 1 minute during day, 15 minutes during night).

Thanks.


3 Answer(s)
  • User Avatar
    0
    alirizaadiyahsi created

    Hi,

    Actually there is no a built-in solution for this. But may be you can try to set timer in DoWork method by a datetime condition I mean something like following:

    Timer.Period = now == day ? "1 minute" : "15 minutes";
    
  • User Avatar
    0
    ivanosw1 created

    I've tried to change the Period in DoWork and it seems works. My doubt is only if this is expected or can cause some stranges side effects.

  • User Avatar
    0
    alirizaadiyahsi created

    I think, it is a stable way to do this for this design.