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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:58:20+00:00 2026-05-28T06:58:20+00:00

I have created a C# COM DLL which is essentially an enhanced progress bar

  • 0

I have created a C# COM DLL which is essentially an enhanced progress bar that runs a System.Windows.Forms.Application.Run() on a new thread to show the form with the dialog. To use it in a third party application using VBA you do something like:

Set pg = CreateObject("MyNS.MyProgressBar")
pg.ShowBar()
.
.
pg.Progress = 0.5
.
.
pg.ShutDownBar()

The problem is that the user is able to close the application (using File->Quit, or similar) BEFORE pg.ShutDownBar() is reached. If the user does this, pg.ShutDownBar() is never called and the result is that although the window of the application is hidden, it still appears in task manager processes.

So my question is:
Is there some way to detect whether the parent application has shut down and then abort the thread for the progress bar in c#?

I have tried System.Windows.Forms.Application.ThreadExit and System.Windows.Forms.ApplicationExit on the main thread that starts the dialog thread, but these events appear not to be raised when accessing the object through COM (though they are called when I create the object in .NET)….

Can anyone provide some advice?

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

    This is problem with the way COM reference counting works. Unless the program calling into your COM wrapper releases the reference (as M. Babcock suggested that would require the program to get to a step where you do “set pg = Nothing”), your progress bar will not get properly shut down.

    The only suggestion I can make is to setup a “timeout” property (and default it to say 30 seconds). Then use a background thread in the progress bar, that checks how long ago the last call to “pg.Progess” was made and if it’s > timeout value, do a shutdown. This is assuming you can expect most VB scripts to report progress at least every X seconds (where X is the timeout value).

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

Sidebar

Related Questions

I have created a .NET DLL which makes some methods COM visible. One method
I have some MSVC++ compiled DLL's for which I have created COM-like (lite) interfaces
I have a VB6 dll that is trying to create a COM object using
I developed an Outlook 2003 add-in which uses the com dll redemption. I created
I have created a application base on .net framework 2.0 in a windows XP
I have a wrapper managed application(.net) over a COM Component(created using vb6) where Com
I have a dll that I created from a VB6 project that I am
I have a .NET dll which has some interfaces\classes which are exposed to com.
I have application which can export slides to PowerPoint. I'm using Microsoft.Office.Interop.PowerPoint.dll . This
I have a C++ DLL project which is created in VS 2010. It 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.