Program with HTTPListener is idling at 100% cpu...

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Hey,

I have made a program, that simply runs as a tray icon in the
systemtray, providing a HTTP Server using HTTPListener.

I have one problem however, it idles at 70-100% cpu.

It could be 1 of 2 things:

1) In my Sub Main i have:

Sub Main()
While CloseProgram = False
Application.DoEvents()
End While
End Sub

I didn't quite know how to do it otherwise (Stop the program closing as
its just a tray icon and no windows forms are present), or its

2) The HTTPListener being greedy.

Any Ideas?

Cheers
 
Tom said:
Hey,

I have made a program, that simply runs as a tray icon in the
systemtray, providing a HTTP Server using HTTPListener.

I have one problem however, it idles at 70-100% cpu.

It could be 1 of 2 things:

1) In my Sub Main i have:

Sub Main()
While CloseProgram = False
Application.DoEvents()
End While
End Sub

I didn't quite know how to do it otherwise (Stop the program closing
as its just a tray icon and no windows forms are present), or its

2) The HTTPListener being greedy.

Any Ideas?


Replace your loop by

Application.Run

And instead of setting CloseProgram = True, call Application.ExitThread.


Armin
 
Back
Top