Click here to Skip to main content
15,891,136 members
Home / Discussions / C#
   

C#

 
AnswerRe: Removing Handler... URGENT Pin
Heath Stewart17-Oct-05 5:58
protectorHeath Stewart17-Oct-05 5:58 
QuestionEncode two integers Pin
JoaoPe15-Oct-05 15:48
JoaoPe15-Oct-05 15:48 
AnswerRe: Encode two integers Pin
Rob Philpott15-Oct-05 23:29
Rob Philpott15-Oct-05 23:29 
AnswerRe: Encode two integers Pin
Heath Stewart16-Oct-05 0:17
protectorHeath Stewart16-Oct-05 0:17 
GeneralRe: Encode two integers Pin
JoaoPe16-Oct-05 2:33
JoaoPe16-Oct-05 2:33 
AnswerRe: Encode two integers Pin
Heath Stewart16-Oct-05 17:14
protectorHeath Stewart16-Oct-05 17:14 
QuestionWinService issues Pin
WetRivrRat15-Oct-05 13:42
WetRivrRat15-Oct-05 13:42 
AnswerRe: WinService issues Pin
Heath Stewart16-Oct-05 0:25
protectorHeath Stewart16-Oct-05 0:25 
ServiceBase.OnStart and ServiceBase.OnStop are meant for initialization and destruction of your service, respectively. They should be as fast as possible, as you've seen. Instead, push all work into a separate thread and simply start the thread.
class MyDbService : ServiceBase
{
  // ...
  public override void OnStart(string[] args)
  {
    // Perhaps open the database connection and allow exceptions to be thrown
    // so that the service doesn't enter a started state when its clearly won't
    // do anything in such a case.
 
    // Start your thread of execution.
    Thread t = new Thread(new ThreadStart(UpdateDb));
    t.Name = "Db Updater";
    t.Start();
  }
 
  public override void OnStop()
  {
    // Make sure database connections are closed.
  }
 
  void UpdateDb()
  {
    // Update the database.
  }
}
You might also consider using a ThreadPool and splitting up units of work based on your inputs and number of connections available from the client to the database. If the database implements connection pooling (depends on connection string options, typically) and a client can open a number of connections to the same database you could get a lot of performance boosts this way.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft

[My Articles] [My Blog]
QuestionRead until "- -" ??? Pin
WetRivrRat15-Oct-05 13:06
WetRivrRat15-Oct-05 13:06 
AnswerRe: Read until "- -" ??? Pin
Robert Rohde15-Oct-05 22:29
Robert Rohde15-Oct-05 22:29 
AnswerRe: Read until "- -" ??? Pin
Scott Serl16-Oct-05 15:00
Scott Serl16-Oct-05 15:00 
Questionvideo streaming, Is it possible Pin
serguey_haftrige15-Oct-05 12:23
serguey_haftrige15-Oct-05 12:23 
AnswerRe: video streaming, Is it possible Pin
leppie15-Oct-05 23:24
leppie15-Oct-05 23:24 
QuestionPersistence Pin
Sled Dog15-Oct-05 11:27
Sled Dog15-Oct-05 11:27 
AnswerRe: Persistence Pin
Rob Philpott16-Oct-05 1:14
Rob Philpott16-Oct-05 1:14 
GeneralRe: Persistence Pin
Sled Dog16-Oct-05 3:54
Sled Dog16-Oct-05 3:54 
GeneralRe: Persistence Pin
Rob Philpott16-Oct-05 4:19
Rob Philpott16-Oct-05 4:19 
GeneralRe: Persistence Pin
Sled Dog16-Oct-05 4:37
Sled Dog16-Oct-05 4:37 
GeneralRe: Persistence Pin
Rob Philpott16-Oct-05 4:54
Rob Philpott16-Oct-05 4:54 
Question"Public Shared" equivalent in VB & Global Pin
Sled Dog15-Oct-05 9:52
Sled Dog15-Oct-05 9:52 
AnswerRe: "Public Shared" equivalent in VB & Global Pin
Sled Dog15-Oct-05 9:59
Sled Dog15-Oct-05 9:59 
AnswerRe: "Public Shared" equivalent in VB & Global Pin
Sled Dog15-Oct-05 11:08
Sled Dog15-Oct-05 11:08 
QuestionDetermining DNS servers with C# Pin
Rob Philpott15-Oct-05 7:45
Rob Philpott15-Oct-05 7:45 
AnswerRe: Determining DNS servers with C# Pin
leppie15-Oct-05 21:24
leppie15-Oct-05 21:24 
GeneralRe: Determining DNS servers with C# Pin
Rob Philpott15-Oct-05 23:54
Rob Philpott15-Oct-05 23:54 

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.