|
Hi,
Now I've implemented a solution which seems to work fine.
This is what I needed to do:
1) Create a 'delegate' which had the same signature as my addToLog(...)-method.
public delegate void myDelegate( string id, string e, TimeSpan ts );
2) Modify the responseThread()-method so that it creates the delegate
myDelegate md = new myDelegate( addToLog );
3) Modify the responseThread()-method so that it calls (or more accurately invokes) the delegate with the appropriate arguments:
so the line that before said:
this.addToLog( ""+(index++), "thread", rTimeDiff );
Now says:
this.Invoke( md, new Object[] { ""+(index++), "thread", rTimeDiff } );
private void responseThread() <br />
{ <br />
string sThreadName = "ResponsePollingThread";<br />
Thread.CurrentThread.Name = sThreadName;<br />
string sTmp = null;<br />
string sSeparator = "\n*************************************\n";<br />
bool found = false;<br />
string searchstring = null;<br />
myDelegate md = new myDelegate( addToLog );<br />
try <br />
{<br />
while( true ) <br />
{<br />
DateTime rTmp = DateTime.Now;<br />
TimeSpan rTimeDiff = rTmp - rStartTimeStamp;<br />
this.Invoke( md, new Object[] { ""+(index++), "thread", rTimeDiff } );<br />
Thread.Sleep( 1000 );<br />
}<br />
}<br />
catch( Exception e ) <br />
{<br />
Console.WriteLine( "Updater-thread ended." );<br />
}<br />
}
|
|
|
|
|
Ok so here's my question:
Does anyone know how to make (in C# of course) a child window that has focus at the same time the parent form does *and* exists outside of the main parent form.
I don't want MDI because it requires the child form to sit inside of the main parent form. I know it's doable in the Windows environment since I have two programs that do this (Photoshop and Flash). Their tool palettes can be clicked on and they do not tear away focus from the main form on the desktop.
I suppose I can cheat and whenever someone clicks on a button inside of the toolpalette (i.e. the child form), call Focus() on the parent form. But like I say I know in the Windows environment it is possible to have both maintain focus. Since Photoshop and Flash both do it.
Does anyone know a way around this? Any help would of course be most valuable and appreciated.

|
|
|
|
|
Hello,I am trying to create <xsl:value-of select="....."> element(... means any string value) in a XML document.I used xmldocument.createElement("xsl:value-of select=\".... "); command.But it is not correct.how can I create xsl instructions in xml document with this method?Or should I try another way?Please help
|
|
|
|
|
Hi there,
I need to get the server time from a server which is located in canada.
Is there any possibility to do this with a direct call to the server without having anything else installed on the server.
I have admin rights on the server and so on.
let me know if you need anymore information 
|
|
|
|
|
I am working on an app that should open a logfile and then it should be possible to:
1. output the whole file as it is
2. reverse the output
3. filter the output
I am outputting to a richtextbox since I also want to highlight specific lines.
I have tried both using ArrayList and StringBuilder. The latter seems better but then it is not so easy to reverse. To add all text to the RichTextBox I use RTB.Text. I have also thought of outputting all to a temp file and use RTB.LoadFile instead.
The problem is that the logfiles can be quite huge, >5MB in extreme cases. This causes it to be very slow and I also encounter out-of-index problems in certain situations that I have not been able to pin down in the debugger.
Could anyone advice me on the best way to get a stable and not to slow solution (since I have to work through the whole file line by line to filter it will never be quick)?
Code extract:
try
{
StreamReader sr = File.OpenText(fileName);
string input = null;
//ArrayList myList = new ArrayList();
StringBuilder sb = new StringBuilder();
while ((input = sr.ReadLine()) != null)
{
if ( Filter or not )
{
Filtering of each line.
If condition met then
sb.Append(input);
//myList.Add(input);
}
}
else {
sb.Append(input);
//myList.Add(input);
//myList.TrimToSize();
}
}
sr.Close();
//myList.TrimToSize();
if ( checkBox4.Checked ) { //myList.Reverse(); }
richTextBox1.Clear();
/*
for (int i=0;i<myList.Count;i++)
{
sb.Append(myList[i].ToString() + "\n");
}
*/
richTextBox1.Text = sb.ToString();
}
catch (Exception e)
{ MessageBox.Show(e.ToString()); }
}
|
|
|
|
|
Obviously, you have to check each line in your file for your filtering condition.
You could use XML instead, for which the .NET Framework has built-in support.
This is not a valid xml file, but you might understand what I am after:
<logfile>
<logdate="22.01.2005"/>
<logdate="23.01.2005">
<errors>
<entry>
....
</entry>
<entry>
....
</entry>
....
....
</errors>
<warnings>
....
....
</warnings>
</logdate>
<logdate="....">
....
</logdate>
</logfile>
Thus, by organizing your data you will be able to find things faster.
Additionally, this already is tree-shaped, so you can easily include it into
a tree view or something and show error-specific details in a rich-text box.
Another way would be to do some organizing yourself. you could have different logfiles for categories, so when the user filters for one category, you simply have to load a file.
Also, filtering is much easier if you perform these operations in RAM, not on disk (by loading each line seperatly instead of buffering first, then filtering later).
Cheers
Sebastian
|
|
|
|
|
Thanks for your answer but unfortunately I have no control of the logfile. It's because it's huge and diifcult to read I'd like to build my own logfile reader.
What I need most I think is a tip on how to reverse output using StringBuilder. Otherwise I do thing StringBuilder is the way to go.
|
|
|
|
|
HI~
I am writing C# and use the CF to write mobile application.
I use the input panel control.
The input panel control provide "EnabledChanged" event handler
I write something like this:
inputPanel1.EnabledChange += new System.EventHandler(this.whenChange);
And then I write:
if (inputPanel1.Enable)
{
inputPanel1.Enable = false;
}
This of course will cause the program execute the "whenChanged(Object sender, SystemArgs e)".
The expected result is happened in the emulator. However, testing the program in a real device cause error. The event handler does not execute. That means the "whenChange(..)" method does not execute.
Why this happen?
Thanks
p.s , the real device has installed .NET CF SP2.
|
|
|
|
|
Hello All,
It is possible with C#? If not, anyway to define my own event
accessor methods as in MC++?
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
hi,
It is possible with C#?
what is possible with C# ?
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
sreejith ss nair wrote:
what is possible with C# ?
Hmmmm, the claim is that it is a better VB, may be not the current version.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
i use directdraw load a bmpfile to a surface,and i want circumgyrate the bmpfile some angle in my program, how to do it? please help me, thanks.
|
|
|
|
|
If you mean draw it rotated then the answer is that you can't. DirectDraw does not support rotation. You'll have to manually rotate it (using GDI+ for example - see the Graphics class and RotateTransform() in it) and make a new bitmap.
|
|
|
|
|
Hello All,
Is there any equivalent to the /fx C++ compiler option
for C#?
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
|
If I could get access to the codes generated for the delegates - hope I could find a way out
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
There was a program called ILDASM that could disassemble a .Net program into IL. Perhaps that might help you? (But chances are delegates are still delegates even at the IL layer)
|
|
|
|
|
Thanks for the support.
EssOEss wrote:
ILDASM
As a C# programmer I should know ILDASM
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Hello,
What is the best way to have something like this?
protected delegate string CalculationDelegate(int count);
protected delegate string CalculationDelegate(double count);
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
|
True? or you are smilling?
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Its a new feature introduced in .NET 2. Delegate overloading and something else (co-ercian i think) that allows u to pass an inherited class into the delegate and/or use a delegate definition taking derived parameters. delegates have/will become alot more powerfull in .NET 2
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
I heard about anonymous delegate stuff, but not the others.
leppie wrote:
delegates have/will become alot more powerfull in .NET 2
Yeah, I planning for the .NET 2, including my IDE
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
I want to run one instance only? How to do it?
Thank yous.
|
|
|
|
|
One way is use Process.GetProcesses() or GetProcessesByName() methods and see if is there any instance of application running.
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|