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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:21:39+00:00 2026-05-24T06:21:39+00:00

this is my question: How could I handle a timeout on a method execution,

  • 0

this is my question:

How could I handle a timeout on a method execution, the scenario is the following:

I have a C# .Net framework 4.0 Windows Service application. I added a reference to a external COM assembly (of a specific software of certain company). With this assembly I intented to process some information against that third party software on my Windows Service, and repeat that task every X minutes (defined by user). This works well on a perfect scenario, the issue is when that third party software has some problems, that assembly just don’t response and my Windows service get stuck on that execution with no answer, for example this is the code of that execution:

    var calObj = new CAL.Object(CalOperatins.SendNoSavingChanges);
//this SYNC execution method sometimes get stuck and 
//the rest of the program just doesn't executes
calObj.TerminateUserSession();

log.Log4Text(string.Format("Service cycle ended, waiting {0} for next execution.",paramTime));
}

As I mentioned on the comments of the code, the execution of TerminateUserSession is synchronous and if that software experiments some problem, my service get stucked in there and the Log4Text method (and everything below it) does not executes.

Is there a way that I can handle a timeout for that TerminateUserSession method execution, keeping in mind that it’s an external assembly and I can’t change that code? (yes, I can figure out that it’s wrong programmed because of the lack of a timeout)

Thanks in advance.

  • 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-24T06:21:40+00:00Added an answer on May 24, 2026 at 6:21 am

    What about running that code on a thread for which you have a handle. You can track the successful execution by toggling a boolean back and forth and kill the thread if it doesn’t respond by the specified timeout. After killing the thread you could relaunch it. However, this is not a perfect solution you might have to recreate your COM object when you kill the thread which always seems to take an excessive amount of time.

    This would also be subject to what is happening in the COM object and if the TerminateUserSessions method can handle the effect.

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

Sidebar

Related Questions

I have this question: How could I call a codebehind method from jquery? I
i have already asked this question on asp.net forum, could not find any satisfactory
This question is related to my ASP.NET MVC 2 development, but it could apply
I have a similar question to this: PHP session timeout callback? Basically, I want
This question is kind of related to Handle URI hacking gracefully in ASP.NET in
This question could be a can of worms, but I've always wondered if it
I suppose this question could just as easily be applied to PHP with regard
Introduction: Now I know this question could be very broad and it would be
I understand that this question could be answered with a simple sentence and that
I was asked this question and could not come up with the answer. Is

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.