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

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
 
A

Armin Zingler

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top