|
|
The escaping routine is for the compiler, and not for the string itself.
If you do Console.WriteLine("line1\\nline2") or Console.WriteLine(@"line1\nline2") , you'll get the same output:
line1\nline2 In the first case, to insert a backslash in the string, you need to double it (otherwise it will be interpreted as a special character: eg. \n as newline). In the second example, the @ means that a different escaping will be performed (most special characters won't be escaped) so \n produces exactly that, \n .
The @ makes a difference when specifying paths in code:
string path1 = "C:\\Program Files\\Microsoft";
string path2 = @"C:\Program Files\Microsoft"; In memory, both path1 and path2 will contain exactly the same.
If you read the string from anywhere typed by the user, you don't have to worry about escape characters. If he types one backslash, you'll get it. Escaping is only when specifying strings in code.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
Luis Alonso Ramos wrote:
The escaping routine is for the compiler, and not for the string itself.
no, I think not, because I get the '@'-problem at runtime.
but I'm happy leppie solved the problem with
sPrompt=sPrompt.Replace(@"\n","\n");
It works!
Thanks leppie
Ariadne
|
|
|
|
|
What that particular line of code is doing is replacing the characters \n (backslash followed by an n ) with an actual newline character. It is the exact equivalent of: sPrompt = sPrompt.Replace("\\n", "\n") .
Somehow you read the sPrompt string from somewhere that doesn't support escaping of characters (a resource maybe?) so you ended up with the characters '\' and 'n' in memory, instead of the actual newline (char 13) character.
But the escaping only works when specifying strings by code, and it's performed by the compiler.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
I have a .net windows client application that queries a .net web service. After the client has called the web service if netstat is run from the command line the results will show 10 sockets still open. Below is the code from my client app. My questions are
1. Why does the client app need 10 sockets?
2. What can I do to force the closing of the sockets since the GC.Collect() & GC.WaitForPendingFinalizers() methods don't seem to be doing it?
3. Does it really matter if the sockets are not immediately closed?
Private Sub LogIn()<br />
If IsUserOffLine() Then Exit Sub<br />
Dim wsEmpInfo As EmpInfoWS.EmployeeInformation = BF.SetUpWS()<br />
Try<br />
wsEmpInfo.SetEmployeeCheckIn(BF.GetUserName, txtLogInComments.Text)<br />
Catch Ex As Exception<br />
Call IsUserOffLine()<br />
Finally<br />
wsEmpInfo.Dispose()<br />
End Try<br />
Dim tRefreshForm As New Thread(New ThreadStart(AddressOf RefreshForm))<br />
Try<br />
tRefreshForm.Start()<br />
Catch ex As Exception<br />
tRefreshForm = Nothing<br />
End Try<br />
End Sub<br />
<br />
Private Sub RefreshForm()<br />
Try<br />
Call PopulateForm()<br />
Call HandleNotify()<br />
Call ShowScrollingNote()<br />
Call CleanUp()<br />
Catch<br />
End Try<br />
End Sub<br />
<br />
Private Sub CleanUp()<br />
Try<br />
GC.Collect()<br />
GC.WaitForPendingFinalizers()<br />
Catch<br />
End Try<br />
End Sub
I appreciate any suggesting you have, thank you.
Jason W.
|
|
|
|
|
It would be very useful to provide the code where you actually call the web service.
www.troschuetz.de
|
|
|
|
|
Not sure if this helps but it's worth a try.
<br />
Public Function SetUpWS() As EmpInfoWS.EmployeeInformation<br />
Dim wsEmpInfo As New EmpInfoWS.EmployeeInformation<br />
wsEmpInfo.Url = GetEmpInfoWSURL()<br />
wsEmpInfo.Credentials = System.Net.CredentialCache.DefaultCredentials<br />
Return wsEmpInfo<br />
End Function<br />
Jason W.
|
|
|
|
|
|
Here is what netstat is showing.
<br />
TCP COMPUTERNAME:4483 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4484 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4485 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4486 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4487 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4488 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4489 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4490 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4491 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4492 111.111.111.111:https TIME_WAIT<br />
Jason W.
|
|
|
|
|
|
Cool, is there a site that tells about the socket status options. I need to point my manager to it so he will get off my back. Thank you for the help.
Jason W.
|
|
|
|
|
|
Trust me I would love to tell him that, at this point I can't however.
Jason W.
|
|
|
|
|
|
|
|
|
|
If it isn't a problem I would like to pick your brain a little more. I found an article that says 'The side shutting down the connection gets the TIME_WAIT.' is this true. If it is then I don't need to worry about causing a denial of service on the server. Thoughts?
Jason W.
|
|
|
|
|
I need to create a program that can simultaneously turn on up to 4 timers that do not control events, but simply record time down to at least a hundredth of a second. This timer must be visibly updated every hundredth of a second on a form to inform the user of the duration of the processes the program is performing. Is there a way to do this in C#? I looked into the Timer control, but can't figure out how to make it work for this purpose.
|
|
|
|
|
Use the Interval property of Timer control to set the time interval after which you want to initiate some action. For example:
Timer.Interval = 10;
Then use the Tick event of the Timer control, which will then fire after every time interval set by you as above. In the event-handler of Tick event, use code to update time in the window as per your requirements.
For example, override the OnPaint method of your window or control where you want to show time and use Graphics methods (Pen , Brush , etc.) to show the actual time. Then in afore-mentioned Tick event-handler, simply use a command like this.Refresh() to refresh the window which will call the OnPaint method to draw / show the updated time after every time interval set by you.
Regards,
Ashok Dhamija
_____________________________
Padam Technologies
|
|
|
|
|
Contrary to what Ashok told you, DON'T use the Timer control. It's resolution is not guaranteed below 15 milliseconds.
You have a couple of problems...
First, are you going to be able to repaint your data every 10 milliseconds AND monitor your process? Not likely. Repainting is slow...
Second, To get the time resolution you want, you really need to use a high resolution timer that is accessed through the QueryPerformanceCounter API. Search the articles for "high resolution timer" and you'll find a bunch of examples and class libraries demonstrating this.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a plug in object that i use in my application
I have 2 interfaces for plugins
IPlugIn
{
}
IMyCompaniesPlugIn:IPlugIn
{
}
when I load a plugin (via Reflection) i want to check whether it is of type IMyCompaniesPlugIn so i can do different stuff for 'known' Plugins
how do i do this test? I can test for any amount of inheritance, but i don't seem to be able to do the same for implementation
Thanks
Russ
|
|
|
|
|
|
thanks
if (myType.GetInterface("MyInterface") != null)
{
}
works perfectly, thanks
Russ
|
|
|
|
|