|
you should try to get more information.
do you use an ide? if yes, which one and does it support breakpoints?! if so, use them.
make sure you see the line, where the timer is started, being executed.
also print out the values of the timer before it get started. compare the code of the other two timers and so on. before starting any timer, you should print its values to make sure its set up correctly. try to debug it because, as you already said, noone will know where to start searching.
|
|
|
|
|
yes I'm stepping thru my code (VS2003) and the interval is getting set. The timer is getting started. It's just never fired.
The last statement that is stepped thru is:
this.autoEvent.Set();
this is in the socket class. It is reseting my events when the socket is closed.
Then control is back at the interface...waiting for the timer to fire.
Tom Wright
tawright915@gmail.com
|
|
|
|
|
Question: can I make my timers avaliable in other classes...so that when the connection is closed, that class can start the timer, instead of me having to fire an event?
thanks
Tom Wright
tawright915@gmail.com
|
|
|
|
|
Sure you can, depending on how you've designed your classes
If you want to make this timer available in other classes you have to have an instance of the class where the timer is in and provide a public interface (e.g. a property) for the other classes.
Also check if your events are bound correctly and let them being fired by some function which definitely works (100%), to make sure that its a problem related with the timer or other code.
You should try to fire the event at least once, to make sure that the timer itself works...
|
|
|
|
|
Are you using the System.Windows.Forms.Timer or the System.Threading.Timer? If you're using the tick event it looks like you're using the windows forms timer. If so, make sure you're using it in a class that inherits from Form , otherwise it won't work. The Threading.Timer is a better option in that case, you can set the interval and a callback function in its constructor.
|
|
|
|
|
It's a forms timer. The timers are setup in my form class. My other timers are working fine.. They start and stop okay.....and they too are being started when the connection event is fired. Then the close event is fired I stop the first two timers and start a thrid timer. This will allow the connection to restart after a certain elasped time. However this third timer is never started. Even though I'm enabling, setting the time interval, and calling the start method.
Thanks
Tom Wright
tawright915@gmail.com
|
|
|
|
|
If you're stopping another timer, why not just change its interval to the interval you had in mind for the third timer and hook up the right event listener to it?
|
|
|
|
|
I have a console application, that shows messages using Console.WriteLine. I have a WinForms application, that runs the console application, and redirects the console output to a TextBox (using ProcessInfo.StartInfo.RedirectStandardOutput ).
When the console output contains the character 'ë' (or '\x00EB'), the TextBox shows it as '‰' (the per mille sign). In the debugger's Locals window, I see the '‰' instead of the 'ë' in the string that has to be displayed, so the error is not in the TextBox.
Why is the 'ë' changed into a '‰'? How can I get it to display correctly? I want to get rid of my current workaround, doing a Replace('‰', 'ë') , because there are other characters (like ï or é) that could cause the same kind of problem.
|
|
|
|
|
Using CharacterMap, take a look at the font that your TextBox is using and the font that the Output window is using. You'll probably see a difference right away.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I don't think so, because I already set the console and the textbox to the same font (Lucida Console). The 'ë' is character '\x00EB', the '‰' is '\x2030', and both show up correctly in the Lucida Console font (as they do in Courier New).
When I searched the string for a character '\x00EB' it just wasn't there. So it is most likely not a matter of font difference, but more a character encoding problem.
|
|
|
|
|
Correct. it has to be an encoding problem.I have never really played a lot with encodings to the console and when I did it was years back. But you might get some hints from "Console.InputEncoding" and "Console.OutputEncoding".
|
|
|
|
|
I created the following function, to try to convert console output to a string that can be displayed in a textbox.
private string ConsoleOutputToUnicode(string consoleOutput)<br />
{<br />
byte[] bConsole = Console.OutputEncoding.GetBytes(consoleOutput);<br />
byte[] bUnicode = UnicodeEncoding.Convert(Console.OutputEncoding, UnicodeEncoding.Unicode, bConsole);<br />
return UnicodeEncoding.Unicode.GetString(bUnicode);<br />
}
I tried other encodings (Default, UTF7, UTF8, UTF32) with the same result, and ASCII resulting in a '?'. Same results with ASCIIEncoding instead of UnicodeEncoding .
The byte[] bConsole is filled with the proper ASCII values ('ë' translates into a byte with the value 137). In a console (or in a message reply box in this thread) type alt-137, and you will see an 'ë'.
In bUnicode I would expect two corresponding bytes with the values 235 and zero (for \x00EB), but I get the values 48 and 32 (so \x2030, which is the per mille sign). Why is that?
One thing I discovered is that typing alt-0137 in a console also gives a '‰'. It is almost like somewhere in the conversion process the leading zero is added.
|
|
|
|
|
It was a thought. I've seen a couple noobie dev's change the font's in the IDE to some really weird ones (Star Trek types) and they wondered why something similar happened to them.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi all,
I was wondering if there is anyway that you could use Math.Round or some other method/class to round numbers off.
Basically if I have the number 19 or 256 etc I would like to round it off to the nearest ten,
ie
19 rounded to 20
256 rounded to 260
I've tried using Math.Round but that only works for decimals.
Any idea's?
TIA
Gav
|
|
|
|
|
The following should work:
double x = 256;
x = Math.Round(x / 10.0) * 10.0;
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
i dont know if there already is a function. if not try this:
<br />
function roundup(int myval)<br />
{<br />
while (myval % 10 != 0)<br />
myval++;<br />
return myval;<br />
}<br />
<br />
usage:<br />
roundup(15);<br />
<br />
output:<br />
20<br />
if you want it to use the "real" rules, you will have to do it like this:
<br />
function round(int myval)<br />
{<br />
int runs = 0;<br />
while ((myval + runs) % 10 != 0)<br />
{<br />
runs++;<br />
}<br />
if (runs < 5)<br />
return (myval - 10);<br />
return myval;<br />
}<br />
EDIT: the post before this one shows another solution which is much simpler and also looks better (since it's using inbuilt technology it probable will be faster too )
|
|
|
|
|
Thanks for replying,Actually i am trying yo convert matlab code into C#,if u can help me then i will send u the code in matlab and also that work that i have done C#, but plz help me
and give me ur mailing id so that i could send u code in attachments
|
|
|
|
|
Hi all,
I have a variable: string TelNo = "(000)000-0000"
How can i trim away the first and second bracket and also the "-" between the zeros. I just want the following value to be in the TelNo Variable...
"0000000000"
Thank you in advance.
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
TelNo.Replace("-", "");
TelNo.Replace("(", "");
TelNo.Replace(")", "");
this will remove ALL "(", ")" and "-" from the string.
|
|
|
|
|
Thank you.
I would never have thought about using replace. I thought i would be something to do with the "Trim().IndexOf"....
Thank you for your time.
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Another way to do it would be to go through the entered string, character-by-character, and add only the numbers to a StringBuilder. When your done searching the string, just call the StringBuilder's .ToString method to return the entered number, sans all the seperation characters and formatting. With this method you get the flexibility of using any seperation characters you want and support for freeform entry of the number.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi:
I am trying to serialize/deserialize a datatable in chunks (say every 10,000 records of a 250,000 record table) using the filemode.append functionality of the binary formatter stream object as follows:
dt.RemotingFormat = SerializationFormat.Binary;
BinaryFormatter formatter = new BinaryFormatter();
Stream output = new FileStream(path, FileMode.Append, FileAccess.Write, FileShare.Write))
formatter.Serialize(output, dt);
This serializes the file to disk just fine. I can watch the size of the resulting disk file increase with each chunk added.
When I attempt to deserialize the file, I only get the first chunk (1st 10,000 records) of data from the datatable and the rest is apparently ignored. Looking at the file in a hex editor, I can see header records for each appended set of records. I believe that the multiple headers are the problem.
I know I have to be overlooking something simple. If you have seen this or solved this, please tell me what I need to do.
Thanks for your time.
John
|
|
|
|
|
Hi,
I have also experienced this. The problem lies in the deserialization of the DataTable. Somehow when deserializing a DataTable it somehow reads some more bytes from the next object in the stream thus destroying the next deserialization step. This not only occurs when using several DataTables but also when you just append some other information after a DataTable. One workaround would be to save your tables in different files. The other possibility would be to add some more custom information to the stream:
Saving:
1. Serialize the table into a MemoryStream.
2. Append the length of the MemoryStream (a simple integer should be alright) to your FileStream.
3. Append the contents of the MemoryStream to the FileStream.
Repeat 1-3 for every DataTable.
The resulting file should logically look somehow likes this:
<Length from Table1><Data from Table1><Length from Table2><Data from Table2><Length from Table3><Data from Table3>...
Loading:
1. Open the FileStream.
2. Deserialize an integer giving you the length of the next DataTable.
3. Deserialize the DataTable.
4. Adjust the Position property of the FileStream to match the length you read at point 2.
Repeat 2-4 for every DataTable (or just until the FileStream is empty).
Robert
|
|
|
|
|
Thanks for the help.
Your suggestion did the trick. Didn't need to mess with the position as it was where it needed to be for the next deserialization.
Thanks again.
|
|
|
|
|
i want to make report that will open DataBase and read two colum
as (select tblUsrs.grad from tblUsrs)
i want to display label with (exlent, very good,good) by use the tblUsrs.grad from tblUsrs
plz how can make this ........
Palestine
|
|
|
|