Re: Threads

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



.... 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









.



Relevant Pages

  • Re: debugging using tk.rb
    ... running the Pig Latin Generator from Dave's book: if I try to debug the pig method with ... ".w00000.w00004 invoke" ... def pig ... TkButton.new{text 'Exit'; command {proc exit}; pack ph} ...
    (comp.lang.ruby)
  • Re: Windows service processing pattern
    ... >worker thread that it should exit at the next opportunity. ... its going to terminate the service process. ... - Service checks for the existance of worker process. ...
    (microsoft.public.dotnet.general)
  • Re: General MPF exit using SYSREXX (SySTEM REXX)
    ... the user exit "MPFEXIT" will get ... MPFEXIT would invoke the SYSREXX exec. ... For IBM-MAIN subscribe / signoff / archive access instructions, ... send email to listserv@xxxxxxxxxxx with the message: GET IBM-MAIN INFO ...
    (bit.listserv.ibm-main)
  • Re: great MASM feature
    ... what will following INVOKE be compiled to: ... exit proto code:dword ... buf db 10 dup ...
    (alt.lang.asm)
  • Re: ntvdm encountered a hard error
    ... cmp eax,-1 ... jne exit ... FileDataL = $ - FileData ...
    (comp.lang.asm.x86)