Quantcast

Maximum PC

It is currently Thu Oct 23, 2014 2:27 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Thread based Error / Event Logging
PostPosted: Thu Sep 25, 2008 9:46 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Okay, I have NO idea if this is possible (or a good idea) but I am getting REALLY annoyed...

So I wrote this error logging class, to specs. It takes 3 objects as parameters, one for the exception, one for System.Relefection.MethodBase.GetCurrentMethod(), and one for a Sql Data object (Data Adapter, Table Adapter, or SQL Command)... spawns a thread, saves info to a DB or dumps a strongly typed dataset to xml...

no worries.

BUT

Code:
try
{
     ///Do Stuff....
}
catch (Exception Ex)
{
     ErrorLogging.LogError(Ex, System.Reflection.MethodBase.GetCurrentMethod(), null);

}


This is a PITA, not to mention, difficult to change if something should change somewhere.

Is it possible to have some object watching a thread, suck in the relevant information (using Reflection, similar to how I am doing it now) and spawn a child/worker thread to do this? Then it just happens no matter where the exception is?

This would be a life saver (as well as helping migrate other apps to use this type of error logging). I would like to use it to prevent the app from job closing too if possible. If it traps an error, it should try to gracefully quit what it was doing and move on (button click, throws an error, it just discards what it was doing and ends the event)?


Top
  Profile  
 
 Post subject:
PostPosted: Thu Sep 25, 2008 9:59 am 
Million Club - 5 Plus*
Million Club - 5 Plus*
User avatar

Joined: Sun Sep 12, 2004 6:37 pm
Posts: 4745
Location: In the monkey's litterbox
Maybe the techniques here could help: http://www.codeproject.com/KB/exception ... dling.aspx


The other option would be to set up a delegate and use thread.start() on it.


Top
  Profile  
 
 Post subject:
PostPosted: Thu Sep 25, 2008 10:16 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
smartcat99s wrote:
The other option would be to set up a delegate and use thread.start() on it.
Okay... I will have to read up on that method. I know very little about delegates.


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

© 2014 Future US, Inc. All rights reserved.