Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8272267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:04:47+00:00 2026-06-08T07:04:47+00:00

I am using II6. I have a Method(LogMessageToSIFDB) that I assume had an exception,

  • 0

I am using II6. I have a Method(LogMessageToSIFDB) that I assume had an exception,

Task.Factory.StartNew(() => LogMessageToSIFDB(inClientID, tmpByte, Modified, SIF_MessageID, SIF_TimeStamp));

The method is quite simple

  1. connect to DB
  2. Call Sproc
  3. Close connection

The DB connection now works fine. The problem I am having is if an exception occurs nothing gets logged anywhere.

If I change up the logic flow, the SProc doesn’t get called and nothing gets logged to Events or anything

  1. throw new ApplicationException(“Hello from LogMessageToSIFDB()”);
  2. connect to DB
  3. Call Sproc
  4. Close connection

In a nutshell, this doesn’t do anything that causes something to get logged.

Task.Factory.StartNew(() => { throw new ApplicationException("Hello from LogMessageToSIFDB()"); });

Here is what I’m trying to do. I have this code in a DLL that implements an interface that Engineering gave me. They pass in a stream that is an XML message. I need to modify that message. I also need to log the original message.

Logging the message to the DB would just cause the IIS thread to block longer, so I figured I would just create a task and let it run async. If the call doesn’t work once in a while, I really don’t care, but if I’m ever debugging a current issue, I need to see an error message.

I was hoping that an unhandled exception in the task would just crop up in the Event Log, but I’m not seeing anything anywhere.

Async logging is not a requirement, but it is preferred. Worst case is just to remove the Task and let it run in sync.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:04:48+00:00Added an answer on June 8, 2026 at 7:04 am

    With Tasks, the expectation is that you are going to observe the exception of the Task somehow: by using Wait() or Result (which throw the exception, enclosed in an AggregateException) or directly by accessing its Exception property.

    If you don’t do that and the Task gets garbage collected, its finalizer will throw the exception, which will bring the whole process down (although .Net 4.5 changes that, the finalizer will no longer throw). But you have to remember that GC is not deterministic and the Task may be collected only after a long time, which is most likely why you don’t see anything.

    What you should do is to somehow observe the exception. If you want to do it asynchronously, you can use ContinueWith() along with OnlyOnFaulted. But an easier way here is to use a normal try–catch:

    Task.Factory.StartNew(() =>
    {
        try
        {
            LogMessageToSIFDB(inClientID, tmpByte, Modified, SIF_MessageID, SIF_TimeStamp));
        }
        catch (Exception ex)
        {
            // perform your logging here
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using report builder 3.0, I have a report that queries a cube. How do
Using CRM 4, I have an entity form that contains a tab with an
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using Android 2.1+. I have a service that gets killed from time to time
Using boost python I need create nested namespace. Assume I have following cpp class
Using Rails 3.1. I have some pages that render same layout, except the contents
I have a hybrid ASP.NET/MVC 2 application that is currently hosted on II6. I
I'm currently in the process of upgrading old II6 automation scripts that use the
Using android 2.3.3, I have a background Service which has a socket connection. There's
We have an ASP.NET 2.0 application that is available as a trial download. As

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.