473,407 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Thread doesn't die

Hello,

I am using p/Invoke to access a card reader device's dll and
I am using a thread to emulate a assync call from a sync call.
Whe I want to read a card, I start a new thead that makes a blocking call
while my application can continue. When the card is read the thread finishes.

But when the operation is canceled I have to kill the thread and it doesn't die.
I've tried to use Abort(), Suspend() and to turn the thread a background thread but it doesn't work.

I thing the thread doesn't die because it's blocked waiting the card.
Is there a way to force this therad to die?

Can somebody helpe me?
--------------------------------
From: ns leonardo

--------------------------------
From: ns leonardo

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>kOuw2cUUD0e6KgCxyvo2Mw==</Id>
Jul 21 '05 #1
2 1235
Try contacting the card reader's manufacturer. If they were nice, they have
a version of the call that times-out.

I cannot think of a way to abort the thread as long as its in non-CLR land,
the runtime has no way to know when it is safe to do so.

--
Jonathan Allen
"ns leonardo via .NET 247" <an*******@dotnet247.com> wrote in message
news:uZ*************@TK2MSFTNGP10.phx.gbl...
Hello,

I am using p/Invoke to access a card reader device's dll and
I am using a thread to emulate a assync call from a sync call.
Whe I want to read a card, I start a new thead that makes a blocking call
while my application can continue. When the card is read the thread finishes.
But when the operation is canceled I have to kill the thread and it doesn't die. I've tried to use Abort(), Suspend() and to turn the thread a background thread but it doesn't work.
I thing the thread doesn't die because it's blocked waiting the card.
Is there a way to force this therad to die?

Can somebody helpe me?
--------------------------------
From: ns leonardo

--------------------------------
From: ns leonardo

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>kOuw2cUUD0e6KgCxyvo2Mw==</Id>

Jul 21 '05 #2
As the OP said, you cannot kill a thread while it is running in unmanaged
code. But....you can try running the thread from another appdomain. When you
need to stop the thread you can unload the appdomain - the runtime goes to
great lengths to kill threads that originate in other appdomains. Don't know
if it will work but it should be easy enough to test.

"ns leonardo via .NET 247" <an*******@dotnet247.com> wrote in message
news:uZ*************@TK2MSFTNGP10.phx.gbl...
Hello,

I am using p/Invoke to access a card reader device's dll and
I am using a thread to emulate a assync call from a sync call.
Whe I want to read a card, I start a new thead that makes a blocking call
while my application can continue. When the card is read the thread finishes.
But when the operation is canceled I have to kill the thread and it doesn't die. I've tried to use Abort(), Suspend() and to turn the thread a background thread but it doesn't work.
I thing the thread doesn't die because it's blocked waiting the card.
Is there a way to force this therad to die?

Can somebody helpe me?
--------------------------------
From: ns leonardo

--------------------------------
From: ns leonardo

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>kOuw2cUUD0e6KgCxyvo2Mw==</Id>

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: phil | last post by:
And sorry I got ticked, frustrating week >And I could help more, being fairly experienced with >threading issues and race conditions and such, but >as I tried to indicate in the first place,...
3
by: David Sworder | last post by:
This message was already cross-posted to C# and ADO.NET, but I forgot to post to this "general" group... sorry about that. It just occured to me after my first post that the "general" group readers...
4
by: cedric | last post by:
hello, I encounter a problem using threads. I have a simple code to use a thread : cSurveillanceBorne = New clsThreadSurveillance _SurveillanceThread = New Thread(AddressOf...
16
by: Alvin Bruney | last post by:
I'm observing that a sleeping thread changes to stopped after a while. Is that accepted framework behavior for web applications? My thread basically does some work, and sleeps for 60 minutes...
7
by: David Sworder | last post by:
Hi, I'm developing an application that will support several thousand simultaneous connections on the server-side. I'm trying to maximize throughput. The client (WinForms) and server communicate...
2
by: ns leonardo via .NET 247 | last post by:
Hello, I am using p/Invoke to access a card reader device's dll and I am using a thread to emulate a assync call from a sync call. Whe I want to read a card, I start a new thead that makes a...
51
by: Hans | last post by:
Hi all, Is there a way that the program that created and started a thread also stops it. (My usage is a time-out). E.g. thread = threading.Thread(target=Loop.testLoop) thread.start() ...
3
by: NaeiKinDus | last post by:
Hello, i'm trying to program a thread that would be locked (by a mutex) and that would only be unlocked once that a function (generating data) is done. The purpose is to generate data, and unlock...
34
by: Creativ | last post by:
Why does Thread class not support IDisposable? It's creating quite some problem. Namely, it can exhaust the resource and you have not control over it.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.