RichTextBox and Timer

G

Goran Djuranovic

Hi all,
I would really appreciate if someone cound point me to the right direction,
regarding the issue I have. Or suggest another solution.

I have a VB.NET windows service that is processing XML files from a specific
folder, and that works fine. But, what I would like to do now is create a
side application (or within the same app) that is responsible for monitoring
the whole process. When I say monitoring, I mean a form that displays which
file has been processed and when. Right now, I can do that by having the
service right to a log file, and than read a log file and store the text
into a read-only RichTextBox control. The refresh of the RTB is controlled
by a Timer control. The problem with this is that the RTB flickers, no
matter how I set the Timer. This is the result of having to get the whole
log file text, bind it to RTB and have it scroll down to the end

Now, I was wondering if there is any other way to accomplish the same thing,
and how?
- Service writes to a command window
- Service appends text directly to a RTB (not sure if I can have a WinForm
as a part of WinService project; maybe separate projects)
- RTB gets only the latest info from log file, since the last timer tick
(read lines from the last end-line to the current end-line, or something
like that)

Any suggestions?

Thanks
Goran Djuranovic
 
G

Goran Djuranovic

In case someone else has the same problem, I have fixed the flickering by
using this:
*************
Private Const WM_SETREDRAW As Int32 = &HB
Private Declare Auto Function SendMessage Lib "user32.dll" (ByVal hwnd As
IntPtr, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32)
As Int32
*************

and this:

*************
SendMessage(RichTextBox1.Handle, WM_SETREDRAW, False, 0)
RefreshTextBox(TextStr)
SendMessage(RichTextBox1.Handle, WM_SETREDRAW, True, 0)
RichTextBox1.Focus()
RichTextBox1.Refresh()
*************

But, I would still like to know if there is any other way for the windows
service to write to a winform or a command window.

TIA
Goran Djuranovic
 

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