Click here to Skip to main content
15,905,420 members
Home / Discussions / C#
   

C#

 
AnswerRe: Creating Libraries in C# Pin
S. Senthil Kumar15-Oct-05 23:10
S. Senthil Kumar15-Oct-05 23:10 
GeneralRe: Creating Libraries in C#[modified] Pin
ddmcr15-Oct-05 23:21
ddmcr15-Oct-05 23:21 
GeneralRe: Creating Libraries in C#[modified] Pin
S. Senthil Kumar16-Oct-05 1:03
S. Senthil Kumar16-Oct-05 1:03 
Questiontext editor Pin
talk2krish15-Oct-05 21:08
talk2krish15-Oct-05 21:08 
AnswerRe: text editor Pin
Robert Rohde15-Oct-05 22:07
Robert Rohde15-Oct-05 22:07 
Questiondirectx video source as a binary stream? Pin
serguey_haftrige15-Oct-05 17:08
serguey_haftrige15-Oct-05 17:08 
AnswerRe: directx video source as a binary stream? Pin
Heath Stewart16-Oct-05 0:33
protectorHeath Stewart16-Oct-05 0:33 
GeneralRe: directx video source as a binary stream? Pin
serguey_haftrige16-Oct-05 14:52
serguey_haftrige16-Oct-05 14:52 
AnswerRe: directx video source as a binary stream? Pin
Heath Stewart16-Oct-05 17:28
protectorHeath Stewart16-Oct-05 17:28 
QuestionRemoving Handler... URGENT Pin
Shubhabrata Mohanty15-Oct-05 16:14
Shubhabrata Mohanty15-Oct-05 16:14 
AnswerRe: Removing Handler... URGENT Pin
Heath Stewart16-Oct-05 0:04
protectorHeath Stewart16-Oct-05 0:04 
GeneralRe: Removing Handler... URGENT Pin
Shubhabrata Mohanty16-Oct-05 11:06
Shubhabrata Mohanty16-Oct-05 11:06 
AnswerRe: Removing Handler... URGENT Pin
Heath Stewart16-Oct-05 17:06
protectorHeath Stewart16-Oct-05 17:06 
GeneralRe: Removing Handler... URGENT Pin
Shubhabrata Mohanty16-Oct-05 20:42
Shubhabrata Mohanty16-Oct-05 20:42 
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 

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.