Click here to Skip to main content
15,910,123 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Don't be hatin': Bill Gates Is Richest Man In the World Again Pin
Mark_Wallace3-Mar-15 21:50
Mark_Wallace3-Mar-15 21:50 
GeneralRe: Don't be hatin': Bill Gates Is Richest Man In the World Again Pin
Rob Grainger4-Mar-15 0:09
Rob Grainger4-Mar-15 0:09 
GeneralRe: Don't be hatin': Bill Gates Is Richest Man In the World Again Pin
H.Brydon3-Mar-15 16:05
professionalH.Brydon3-Mar-15 16:05 
GeneralRe: Don't be hatin': Bill Gates Is Richest Man In the World Again Pin
Pete O'Hanlon3-Mar-15 17:01
mvePete O'Hanlon3-Mar-15 17:01 
GeneralRe: Don't be hatin': Bill Gates Is Richest Man In the World Again Pin
H.Brydon6-Mar-15 8:12
professionalH.Brydon6-Mar-15 8:12 
GeneralRe: Don't be hatin': Bill Gates Is Richest Man In the World Again Pin
90823654-Mar-15 5:07
90823654-Mar-15 5:07 
GeneralRe: Don't be hatin': Bill Gates Is Richest Man In the World Again Pin
H.Brydon6-Mar-15 8:16
professionalH.Brydon6-Mar-15 8:16 
GeneralAfter several false starts Pin
#realJSOP3-Mar-15 7:29
professional#realJSOP3-Mar-15 7:29 
This is NOT a programming question. I just figured that since a few of you are programmers, you might be interested in what I'm doing.

I made a preliminary test run of my Sql Express Agent Service code. This is exercising the Timer agents (agents that run at a specified interval (or on a certain day/date). Multiple agent tasks can be implemented via app.config entries. The intervals for the three tasks represented below are set at 1 minute (Interval Task 01), two minutes (Interval Task 2), and 3 minutes (Interval Task 03).

12:11 AgentTimerTest01 - started module
12:11 Interval Task 01 - Tick
12:11 Interval Task 02 - Tick
12:11 Interval Task 03 - Tick
The thread 0x14edc has exited with code 259 (0x103).
12:12 Interval Task 01 - Tick
The thread 0x1564c has exited with code 259 (0x103).
12:13 Interval Task 01 - Tick
12:13 Interval Task 02 - Tick
The thread 0x14ea8 has exited with code 259 (0x103).
12:14 Interval Task 01 - Tick
12:14 Interval Task 03 - Tick
The thread 0x15768 has exited with code 259 (0x103).
12:15 Interval Task 01 - Tick
12:15 Interval Task 02 - Tick
The thread 0x157e0 has exited with code 259 (0x103).
12:16 Interval Task 01 - Tick
The thread 0x15518 has exited with code 0 (0x0).
The thread 0x15704 has exited with code 259 (0x103).
The thread 0x28b0 has exited with code 259 (0x103).
12:17 Interval Task 01 - Tick
12:17 Interval Task 02 - Tick
12:17 Interval Task 03 - Tick


Each add-in module will be hot pluggable, and will be reconfigurable via its config file, as well as reconfigurable tasks - while the service is running. Currently there are three supported agent classes:

Timer - time-based agents (uses my Schedule Future Dates article)
FileSystem - watches the specified folder for the specified file mask (uses my FileWatcherEx article)
WebRequest - derived from the Timer agent, and performs a web request on the configured URL at the specified time/date interval

One or more of each type of agent can be configured for each plug-in module.

I've restarted this project from scratch five times so far, and I think I've finally got a solid start. The absolute biggest hurdle has been abstracting behavior to lessen the amount of work that's required to write for new modules.

Here's the "do work" code:

C#
protected void DoWork(AgentTask taskObj)
{
    this.DoAgentWork();
    DateTime targetTime = DateTime.Now;
    do
    {
        // find our target time
        targetTime = targetTime.GetFutureDateTime(this.Config.Schedule, this.Config.TimeOfDay, this.Config.DayOfWeek, this.Config.Ordinal, this.Config.Month);

        CancellationTokenSource tokenSource = new CancellationTokenSource(targetTime - DateTime.Now);
        Task waiter = new Task(() => 
        {
            SpinWait.SpinUntil( () => tokenSource.IsCancellationRequested || taskObj.CancelToken.IsCancellationRequested);
        }, tokenSource.Token);
        waiter.Start();
        waiter.Wait();
        if (!taskObj.CancelToken.IsCancellationRequested)
        {
            this.DoAgentWork();
        }
    } while (!taskObj.CancelToken.IsCancellationRequested);
}

private void DoAgentWork()
{
    Debug.WriteLine("{0} {1} - Tick", DateTime.Now.ToString("hh:mm"), this.Config.Name);
}

".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013



modified 3-Mar-15 14:06pm.

GeneralRe: After several false starts Pin
Slacker0073-Mar-15 8:06
professionalSlacker0073-Mar-15 8:06 
JokeRe: After several false starts Pin
ZurdoDev3-Mar-15 8:07
professionalZurdoDev3-Mar-15 8:07 
GeneralRe: After several false starts Pin
TheGreatAndPowerfulOz3-Mar-15 8:13
TheGreatAndPowerfulOz3-Mar-15 8:13 
JokeRe: After several false starts Pin
ZurdoDev3-Mar-15 8:17
professionalZurdoDev3-Mar-15 8:17 
JokeRe: After several false starts Pin
TheGreatAndPowerfulOz3-Mar-15 8:23
TheGreatAndPowerfulOz3-Mar-15 8:23 
GeneralRe: After several false starts Pin
TheGreatAndPowerfulOz3-Mar-15 8:22
TheGreatAndPowerfulOz3-Mar-15 8:22 
GeneralRe: After several false starts Pin
#realJSOP3-Mar-15 8:25
professional#realJSOP3-Mar-15 8:25 
GeneralRe: After several false starts Pin
TheGreatAndPowerfulOz3-Mar-15 8:26
TheGreatAndPowerfulOz3-Mar-15 8:26 
GeneralRe: After several false starts Pin
Richard Deeming3-Mar-15 8:24
mveRichard Deeming3-Mar-15 8:24 
GeneralRe: After several false starts Pin
#realJSOP3-Mar-15 8:27
professional#realJSOP3-Mar-15 8:27 
GeneralRe: After several false starts Pin
Richard Deeming3-Mar-15 8:33
mveRichard Deeming3-Mar-15 8:33 
GeneralRe: After several false starts Pin
#realJSOP3-Mar-15 8:37
professional#realJSOP3-Mar-15 8:37 
GeneralRe: After several false starts Pin
Richard Deeming3-Mar-15 8:41
mveRichard Deeming3-Mar-15 8:41 
GeneralRe: After several false starts Pin
TheGreatAndPowerfulOz3-Mar-15 8:49
TheGreatAndPowerfulOz3-Mar-15 8:49 
GeneralRe: After several false starts Pin
#realJSOP3-Mar-15 8:59
professional#realJSOP3-Mar-15 8:59 
JokeRe: After several false starts PinPopular
Corporal Agarn3-Mar-15 8:55
professionalCorporal Agarn3-Mar-15 8:55 
GeneralRe: After several false starts Pin
Slacker0073-Mar-15 9:01
professionalSlacker0073-Mar-15 9:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.