473,387 Members | 3,810 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,387 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 1233
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.