Calling threadName.Kill in App.CancelClose errors with "This item does not exist"

Hi Folks,

I’ve identified what appears to be an application hang with one of our customers where when they Quit one of our apps, the window closes, but the App continues to run. It turns out that there can be a sequence where a long running thread can be started and the user then elects to Quit. The Quit closes the open windows, but the thread which could run for 3 or 4 minutes is still running.

In App.CancelClose, I added a call to thLoadTapeState.Kill (the thread that’s running), but the compiler tells me “This item does not exist” with the Kill highlighted.

thLoadTapeState is a global project object and is not assigned to a specific window or code module.

Any ideas?

Also, wrapping the call in:

If thLoadTapeState.State <> Thread.NotRunning Then thLoadTapeState.Suspend End If
reports that the State property does not exist…

I get the very same error for a thread placed the same way. But if I put a subclass on a window, then the State property is recognized. Maybe you can use that for a workaround.

Thanks, Michel. I’ll try that immediately.

is thLoadTapeState a global variable defined in a module as a property ?
is it namespaced ?
I’m not exactly clear on how its defined which probably plays into why the compiler thinks it doesn’t exist

I added a Thread to the project and added the Run code.

In the App.Open, I call it and it runs. It’s only when I am trying to Kill it in CancelClose that the Item Not Found occurs.

If you truly added it to the project, then that is just the subclass definition. You have to be acting on an instance.

What does that code look like? Is it literally thLoadTapeState.Run? Or is it something else? If app.Open can execute thLoadTapeState.Run, then app.CancelClose can execute thLoadTapeState.Kill. So there’s something you’re not telling us.

I literally call thLoadTapeState.Run in App.Open.

And thLoadTapeState is not dimmed locally to Where is it defined? In App? In a Module? in a Window?

And if you hover the mouse over “thLoadTapeState” in app.Open and again in app.CancelClose, does the IDE show the same location for each?

Do you have a test project for this? I’d like to test this.