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 7619155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:36:39+00:00 2026-05-31T03:36:39+00:00

Any help with this one greatly appreciated… I have a WPF application, and I

  • 0

Any help with this one greatly appreciated…

I have a WPF application, and I am trying to leverage the Enterprise Library (v5) logging capability to capture certain events. The application is all .Net 4.0.

I have several long running processes, and am using the Task Parallel Library to multithread where necessary. I use the Task.Factory.StartNew syntax, and have several continuations to control flow.

The chain of events finishes with a call to a method I run back on the UI thread, allowing me to udpate various UI components and the like. Wtihin this method I am also trying to write to my log… and the application simply hangs.

To summarise:

1) I have a static ‘logging’ class to allow me to resolve an instance of the Logger with the usual method:

public static void LogThis(string message)
{    
LogWriter logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
logWriter.Write(message, "My Default Logging Category");
}

2) I have a Task Factory call which kicks off my long running work:

...
var longProcess = Task.Factory.StartNew(() => ThisMethodTakesAWhile(variable));
...

3) This task finishes, via continuation, with a call to my ‘wrap things up’ method:

... 
// longProcess is the task coming out of the Factory call in point 2.
// We use the Current Sync Context to allow us to come back to the UI thread.
longProcess.ContinueWith(ant => WrapThingsUp(ant.Result), CancellationToken.None, TaskContinuationOptions.NotOnFaulted, TaskScheduler.FromCurrentSynchronizationContext());
...

4) My ‘wrap things up’ method attempts to log:

private void WrapThingsUp(string resultOfLongProcess)
{
//This call locks the applicaiton.
LogThis("Just to let you know I've finished that long task");
// I never get here!
}

My Logging is configured to target a rolling flat file, in a local folder. Any calls from the UI thread work without issue. It seems to ONLY be the calls from out of the TPL that lock.

I have read articles about not being able to write to a single file simultaneously from multiple source (which I am not trying to do, I’m ensuring in point 4 above that nothing else is trying to log).

I have also seen the article here about thread safety, and I wonder if that is related.

EDIT: I’ve also tried calling the log write explicitly as discussed here, which is pinged in the StackOverflow article here.

EDIT: I’m convinced this is to do with the UI / Dispatcher, as right clicking rapidly on the applications task bar item ‘wakes’ it up.

If I can add any more detail, please let me know.

  • 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-05-31T03:36:40+00:00Added an answer on May 31, 2026 at 3:36 am

    First off, use a static constructor to init your static logger, and use a static field to communicate with it.
    you are wasting a lot of overhead using the factory constntly (it checks the config file every time you log something).

    that being said,

    I created a simple TPL example that just sleeps for random amounts of time (between 8 and 10 min) before returning to the UI, it sends updates via AsyncOperationManager, to the UI and everything works.

    I could not repeat your issue. can you elaborate more ?

    using EL 5.0

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Any help here would be greatly appreciated. I have this table hospital Nurse |
^.+\\(.*\\) I am struggling to work this one out, any help would be greatly
Okay, this one seems to me a bit weird. Any help would be greatly
I have given up on solving this one on my own, and any help
Can Any one help me reading this XML and Looping through <MedicationDispensed> I get
Can any one please help me solve this. I am resizing some flash object/embed
I'm relatively new to Java and would appreciate any help on this! I have
Any help most appreciated, this is driving me insane. I'm doing exactly what I
Been struggling with this for quite some time so any help is appreciated. Spent
Been trying to figure this one out all day. I have a large text

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.