Click here to Skip to main content
15,884,628 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# StreamReader blocks ? Pin
Colin Angus Mackay1-Jan-04 11:53
Colin Angus Mackay1-Jan-04 11:53 
GeneralRe: C# StreamReader blocks ? Pin
Luther Baker1-Jan-04 19:22
Luther Baker1-Jan-04 19:22 
GeneralC# select equivalent Pin
Luther Baker1-Jan-04 11:20
Luther Baker1-Jan-04 11:20 
GeneralRe: C# select equivalent Pin
Heath Stewart2-Jan-04 5:12
protectorHeath Stewart2-Jan-04 5:12 
GeneralRe: C# select equivalent Pin
Luther Baker2-Jan-04 7:58
Luther Baker2-Jan-04 7:58 
GeneralRe: C# select equivalent Pin
Heath Stewart2-Jan-04 9:06
protectorHeath Stewart2-Jan-04 9:06 
GeneralRe: C# select equivalent Pin
Luther Baker2-Jan-04 10:19
Luther Baker2-Jan-04 10:19 
GeneralRe: C# select equivalent Pin
Luther Baker2-Jan-04 11:14
Luther Baker2-Jan-04 11:14 
Ok, that works even faster and now I don't have to manually deal with threading.

As a side note, when using ReadLine, I noticed my problem again. Here's what I did:

Open notepad, type a few lines, DO NOT newline, save the file.

The tail callback works perfectly. The new text is echoed to the TextBox (I manually insert a new line since ReadLine stripped it.)

Type in a few more characters and save again (still, never typing a newline).

The tail callback misses the first two chars!!

So, I opened cygwin - and got the same behavior!!!

As I believe you explained, tail is reading a line at a time. When I don't type a newline and simply save new text into the file - expecting it to be echoed, it doesn't pick up the first two chars (something do to with expectation of \r\n I would guess).

If I DO type a newline and then save, the following text is read correctly from the first char.

So, that means ReadLine works just fine for what I'm doing - which further simplifies this.

Thanks,

-Luther

One last tidbit, I've implemented native calls to scroll the screen with line appended. Unfortunately, its possible these windows won't have focus when they are tailing files - and it seems that the built in TextBox/RichTextBox must have focus and move manually move the caret and then must scroll to the caret. Awfully cumbersome.

I've wrapped the calls in a class, but they are similar to this:

public readonly uint EM_LINESCROLL = 0x00B6;
public readonly uint EM_GETFIRSTVISIBLELINE = 0x00CE;
public readonly uint EM_GETLINECOUNT = 0x00BA;

[DllImport("User32.dll")]
public static extern int SendMessage(IntPtr hWnd, uint Msg, uint wParam, uint lparam);

private void button1_Click(object sender, System.EventArgs e)
{
int line = SendMessage(richTextBox1.Handle, EM_GETFIRSTVISIBLELINE, 0, 0);
int linecount = SendMessage(richTextBox1.Handle, EM_GETLINECOUNT, 0, 0);
SendMessage(richTextBox1.Handle, EM_LINESCROLL, 0, (uint)(linecount - line - 2));
}


Oddly, TextBox scrolls one line at at time. RichTextBox scrolls a page at a time ... unusable for what I'm doing.


Generalinternet dial Pin
heba_zien1-Jan-04 11:09
heba_zien1-Jan-04 11:09 
GeneralRe: internet dial Pin
Heath Stewart2-Jan-04 4:50
protectorHeath Stewart2-Jan-04 4:50 
GeneralFiltered DataGrid Pin
Heroz1-Jan-04 7:23
Heroz1-Jan-04 7:23 
GeneralRe: Filtered DataGrid Pin
Angel Reyes1-Jan-04 7:35
Angel Reyes1-Jan-04 7:35 
GeneralRe: Filtered DataGrid Pin
Mazdak1-Jan-04 7:44
Mazdak1-Jan-04 7:44 
GeneralRe: Filtered DataGrid Pin
Heroz1-Jan-04 11:44
Heroz1-Jan-04 11:44 
Questionplease, can any one help me? Pin
ImanMahmoud1-Jan-04 6:22
ImanMahmoud1-Jan-04 6:22 
AnswerRe: please, can any one help me? Pin
Angel Reyes1-Jan-04 7:54
Angel Reyes1-Jan-04 7:54 
Generalrounded form Pin
hebzzz1-Jan-04 3:34
hebzzz1-Jan-04 3:34 
GeneralRe: rounded form Pin
Jacky S1-Jan-04 4:47
Jacky S1-Jan-04 4:47 
Generallike this for the form.... Pin
eggie51-Jan-04 6:26
eggie51-Jan-04 6:26 
QuestionHow to handle storage in C#/.NET Pin
Mohsen Sajjadi1-Jan-04 3:18
Mohsen Sajjadi1-Jan-04 3:18 
AnswerRe: How to handle storage in C#/.NET Pin
Mazdak1-Jan-04 5:31
Mazdak1-Jan-04 5:31 
GeneralRe: How to handle storage in C#/.NET Pin
Mohsen Sajjadi1-Jan-04 20:56
Mohsen Sajjadi1-Jan-04 20:56 
AnswerRe: How to handle storage in C#/.NET Pin
Heath Stewart2-Jan-04 4:41
protectorHeath Stewart2-Jan-04 4:41 
GeneralChanging paper size at run time Pin
Yaron K.31-Dec-03 23:06
Yaron K.31-Dec-03 23:06 
GeneralRe: Changing paper size at run time Pin
Heath Stewart2-Jan-04 4:33
protectorHeath Stewart2-Jan-04 4:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.