Re: Threads
- From: Sergey Bogdanov <sergey.bogdanov@xxxxxxxxx>
- Date: Wed, 23 Nov 2005 00:19:56 +0200
.... and the best way for me to detect what threads are hanging is to run application in Debug Mode (F5) and invoke a close event from your application. Wait for a moment and then break all threads by using Debug->Break All button. Now you can switch between threads in a Debug->Windows->Threads window and see what happened with each of them.
-- Sergey Bogdanov [.NET CF MVP, MCSD] http://www.sergeybogdanov.com
Julian Sanz wrote:
yes, this is the problem but i don't know how i can solve it
"<ctacke/>" <ctacke_AT_OpenNETCF_com> escribiу en el mensaje news:O%231aWZ27FHA.3984@xxxxxxxxxxxxxxxxxxxxxxx
Sounds like you still have other threads running.
-Chris
"Julian Sanz" <jsanzg@xxxxxx> wrote in message news:O$F$Ty17FHA.3660@xxxxxxxxxxxxxxxxxxxxxxx
it doesnґt work.
I have this code in the sub main method:
Dim oHomeForm As HomeForm
Dim oMyClass1 As MyClass1
Dim oMyClass2 As MyClass2
Dim PosicionThread As OpenNETCF.Threading.ThreadEx
Dim RegistrarThread As OpenNETCF.Threading.ThreadEx
Try
oHomeForm = New HomeForm
oMyClass1 = New MyClass1
PosicionThread = New OpenNETCF.Threading.ThreadEx(AddressOf oMyClass1.ObtenerBLPosicion)
PosicionThread.Start()
RegistrarThread = New OpenNETCF.Threading.ThreadEx(AddressOf oMyClass1.RegistrarBLPosicion)
RegistrarThread.Start()
Application.Run(oHomeForm)
oHomeForm.Dispose()
oMyClass1.Exit = True
PosicionThread.Join()
RegistrarThread.Join()
oMyClass2= New MyClass2
oMyClass2.EliminarAcceso()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OKOnly & MsgBoxStyle.Critical)
Finally
Application.Exit()
End Try
ObtenerBLPosicion And RegistrarBLPosicion has more o less this code:
public class MyClass1
private shared _salir as Boolean
Public Property Salir as Boolean Get Set end property
public sub method()
do while true ...... if _salir then exit sub end if ....... loop
end sub
end class
When i call "Join" method, the main thread wait to exit the others, but when "main" method finish, the application not finish.
Sorry for my english. I hope you understand me.
"Simon Hart" <srhartone@xxxxxxxxx> escribiу en el mensaje news:OizBwV17FHA.3660@xxxxxxxxxxxxxxxxxxxxxxx
When the user tries to close the form you need to set a static flag that the worker process reads on a regular basis, don't allow the end user to exit until the threads are terminated. One way you can manage this more easily is by using OpenNETCF.Threading class using the "Join" method.
See http://www.opennetcf.org
"Julian Sanz" <jsanzg@xxxxxx> wrote in message news:e6CpDJ17FHA.1028@xxxxxxxxxxxxxxxxxxxxxxx
The problem is that user close all forms but application not end because there are 2 threads running. And then i can't execute again the same application until i reset the device.
"Simon Hart" <srhartone@xxxxxxxxx> escribiу en el mensaje news:%230BSAB17FHA.2152@xxxxxxxxxxxxxxxxxxxxxxx
It's bad practice to terminate a thread. You need to check some flag periodcially during your worker thread to determine whether the user want to end the process or not.
Cheers Simon.
"Julian Sanz" <jsanzg@xxxxxx> wrote in message news:%23eUb0707FHA.3224@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
I have had to developped an application for PocketPC. In this application, I create 2 threads but then i canґt kill them and i canґt close completly the application.
їHow can i kill these threads?
Thanks
.
- Follow-Ups:
- Re: Threads
- From: Daniel Moth
- Re: Threads
- References:
- Threads
- From: Julian Sanz
- Re: Threads
- From: Simon Hart
- Re: Threads
- From: Julian Sanz
- Re: Threads
- From: Simon Hart
- Re: Threads
- From: Julian Sanz
- Re: Threads
- From: <ctacke/>
- Re: Threads
- From: Julian Sanz
- Threads
- Prev by Date: Re: GPS API
- Next by Date: About mscoree.stat
- Previous by thread: Re: Threads
- Next by thread: Re: Threads
- Index(es):
Relevant Pages
|