Click here to Skip to main content
15,896,915 members
Home / Discussions / C#
   

C#

 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie22-Nov-11 11:43
CCodeNewbie22-Nov-11 11:43 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon22-Nov-11 22:51
mvePete O'Hanlon22-Nov-11 22:51 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie22-Nov-11 23:06
CCodeNewbie22-Nov-11 23:06 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon23-Nov-11 0:53
mvePete O'Hanlon23-Nov-11 0:53 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie23-Nov-11 1:12
CCodeNewbie23-Nov-11 1:12 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon23-Nov-11 1:22
mvePete O'Hanlon23-Nov-11 1:22 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie23-Nov-11 10:19
CCodeNewbie23-Nov-11 10:19 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon23-Nov-11 23:44
mvePete O'Hanlon23-Nov-11 23:44 
Not quite. I would create a second class - this does nothing with regards to service management, and it would look something like this:
C#
public class TimedEventManager
{
  private BackgroundWorker bw = new BackgroundWorker();
  public void Initialise()
  {
    bw.DoWork += CheckForId();
    bw.RunWorkerAsync(null);
    // Set up the timers/threads as you need here.
  }

  private void CheckForId(object sender, DoWorkEventArgs e)
  {
    bw.DoWork -= CheckForId();
    bw.Dispose();
    // This is where I would call the necessary data access stuff and populate
    // the Id.
  }

  public int Id { get; set; }
  // Other necessary properties and methods here.
}
Then, in your service class, I would create an instance of this:
C#
private TimedEventManager timedEvent;
protected override OnStart(string[] args)
{
  timedEvent = new TimedEventManager();
  // As
  timedEvent.Initialise();
}
And that's it. That's how you hook it together.

Forgive your enemies - it messes with their heads

"Mind bleach! Send me mind bleach!" - Nagy Vilmos


My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility


GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie24-Nov-11 9:55
CCodeNewbie24-Nov-11 9:55 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon24-Nov-11 22:30
mvePete O'Hanlon24-Nov-11 22:30 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie24-Nov-11 22:32
CCodeNewbie24-Nov-11 22:32 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon24-Nov-11 22:48
mvePete O'Hanlon24-Nov-11 22:48 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie24-Nov-11 22:51
CCodeNewbie24-Nov-11 22:51 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie25-Nov-11 10:51
CCodeNewbie25-Nov-11 10:51 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon30-Nov-11 5:34
mvePete O'Hanlon30-Nov-11 5:34 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie30-Nov-11 8:55
CCodeNewbie30-Nov-11 8:55 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon30-Nov-11 11:13
mvePete O'Hanlon30-Nov-11 11:13 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie30-Nov-11 11:21
CCodeNewbie30-Nov-11 11:21 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon30-Nov-11 11:29
mvePete O'Hanlon30-Nov-11 11:29 
AnswerRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon21-Nov-11 8:48
mvePete O'Hanlon21-Nov-11 8:48 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie21-Nov-11 21:45
CCodeNewbie21-Nov-11 21:45 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon21-Nov-11 22:01
mvePete O'Hanlon21-Nov-11 22:01 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie21-Nov-11 22:53
CCodeNewbie21-Nov-11 22:53 
QuestionDeploying C# Application with Crystal report Pin
akosidandan19-Nov-11 23:51
akosidandan19-Nov-11 23:51 
AnswerRe: Deploying C# Application with Crystal report Pin
akosidandan20-Nov-11 1:39
akosidandan20-Nov-11 1:39 

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.