|
I'm attempting to split a file containing records into a number of substrings. The file spec allows for the normal delimiter (') to be escaped within a record by being prefixed with a question mark. Unless there is some trick to it, I guess this rules out using String.Split() so I wrote the following
static ArrayList DealWithEscapedCharacters(StreamReader inputStream, char segmentTerminator, char escapeCharacter)
{
ArrayList results = new ArrayList();
string tempBuffer = "";
char previousChar = ' ';
char currentChar;
while (!inputStream.EndOfStream)
{
currentChar = (char)inputStream.Read();
if (currentChar == segmentTerminator && previousChar != escapeCharacter)
{
tempBuffer += currentChar;
results.Add(tempBuffer);
tempBuffer = "";
}
else
{
tempBuffer += currentChar;
}
previousChar = currentChar;
}
return results;
}
This works, and is very quick even on my laptop. However, can anyone suggest a better/more flexible/even more performant approach?
Me: Can you see the "up" arrow?
User:Errr...ummm....no.
Me: Can you see an arrow that points upwards?
User: Oh yes, I see it now!
-Excerpt from a support call taken by me, 08/31/2007
|
|
|
|
|
There should be a performance gain in using List<string> as supposed to ArrayList where the strings will be boxed.
Larantz-
|
|
|
|
|
Is there any way in which I can use WCF and NetNamedPipeBinding for Interprocess communication? If yes then can someone share the idea of how it can be done?
I want to communicate with different processes on the same machine and processes will also be the instance of the same application.
Krunal C
|
|
|
|
|
I've never used it but according to the documentation yes.
KrunalC wrote: If yes then can someone share the idea of how it can be done?
Is the example in the documentation lacking? If so what is missing?
|
|
|
|
|
led mike wrote: Is the example in the documentation lacking? If so what is missing?
Document only explains the how service and client(consumer) can be configured but don't explain how it can be used for inter process communication.
|
|
|
|
|
|
Hi
In recent times I often get an application error that it is impossible to create a new control object, because there are no more window handles left. The application is written in C# (.Net 1.1) and is used to create extensive content specific dialogues. At the moment I’m not quite sure how to identify the source of error. Within my object model, I use every time dispose() to destroy any existing graphical object. But it seems that this process doesn’t work correct. It is possible to retrieve the number of window handles that are currently used by an application? Last week I read a thread that states to locate the application process and then use the MainWindowHandle property in relation with EnumWindows to get the total count of all window handles. Unfortunately, I’ have no idea how to implement this procedure (especially how shall I use EnumWindows). Does anyone knows how to perform this task or does anyone have another idea to determine the total count of used window handles?
Thanks in advance
Erik
|
|
|
|
|
|
That’s right. In my opinion, I have used up all window handles. It doesn’t happen at once, but it is an ongoing process. It seems that I don’t destroy every created control. Therefore an advisor can process normally a lot of orders, before the error occurs.
|
|
|
|
|
Hi!
There's a thread on this topic a few entries down the page:
here
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hi,
thanks for the excellent link. This is exactly what I was looking for. Using GetGuiResources shows that even if I dispose (or I think that I dispose them) the gui objects, not all used window handles were disposed. Just to give a small example:
Before opening an order : 204 / 375
After opening an order : 370 / 1988
After closing an order : 267 / 699
I guess that if everything would work correct the total numbers of available gui handles after closing an order should be the same as before opening the order. Is there any way to detect this memory leak?
Regards
Erik
|
|
|
|
|
Microsoft has a free tool called the CLR Profiler that can alert you to memory leaks. Commercial apps such as Ants Profiler also can alert you to memory leaks.
|
|
|
|
|
Hi all.
how can I fire a keydown / keyup event?
|
|
|
|
|
Look at the SendKeys class.
|
|
|
|
|
|
I've realized a custom UserNamePasswordValidator.
And I can't run my Service anymore.
if I remove the line :
tcpBinding.Security.Mode = SecurityMode.Message;
it works again, but without user validation....
here the source:
class Program
{
static void Main(string[] args)
{
ServiceHost myHost = new ServiceHost(typeof(classServerFunktionen));
NetTcpBinding tcpBinding = new NetTcpBinding();
tcpBinding.TransactionFlow = false;
tcpBinding.Security.Mode = SecurityMode.Message;
tcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
myHost.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = System.ServiceModel.Security.UserNamePasswordValidationMode.Custom;
myHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new CustomUserNameValidator();
myHost.AddServiceEndpoint(typeof(IServerFunktionen), tcpBinding, "net.tcp://localhost:8777/MyProdService");
//Server starten
myHost.Open();
Console.WriteLine("The service is ready.");
Console.WriteLine("Press <enter> to terminate service.");
Console.ReadLine();
//Server schließen
myHost.Close();
}
}
public class CustomUserNameValidator : System.IdentityModel.Selectors.UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
if (null == userName || null == password)
{
throw new ArgumentNullException();
}
if (!(userName == "test1" && password == "1tset") && !(userName == "test2" && password == "2tset"))
{
throw new System.IdentityModel.Tokens.SecurityTokenException("Unknown Username or Incorrect Password");
}
}
}
//Implementierung des Interfaces mit den Serverfunktionen...
public class classServerFunktionen : IServerFunktionen
{
public String rights;
public String getMessage()
{
return "Hallo Session:" + OperationContext.Current.SessionId;
}
public String getMessage2()
{
return "Hallo2 Session:" + OperationContext.Current.SessionId;
}
}
and my interface:
[ServiceContract]
public interface IServerFunktionen
{
[OperationContract] //(ProtectionLevel = ProtectionLevel.EncryptAndSign)
String getMessage();
[OperationContract]
String getMessage2();
}
|
|
|
|
|
I get the error thet the ChannelDispatcher can't open his IChannelListener
|
|
|
|
|
I need code in C# to populate checkbox in gridview to delete records.
Please help.
Thank you
Saranya
|
|
|
|
|
SJSaranya wrote: populate checkbox in gridview to delete records.
Add a column to the datatable, which you want to assign as a data source to the gridview
like the following
dataTable1.Columns.Add("Name of My Column for the checkbox",typeof(bool),"0");
assign it as datasource.
kss
|
|
|
|
|
I have written code for windows application using C# where in on a button click, a new memo should be opened with email id, subject and body. I am using the code below
System.Diagnostics.Process.Start(String.Format("mailto:{0}?Subject={1}&Body={2}" , txtContEmail.Text.Trim(), strSubject, strBody));
The above code is working if the text specified in the variable strBody is short. But I have to create a body with the text given below
"Dear Customer,
Thank you for utilizing the the application.
The following license file(s) will expire in few days: .
The application will not operate with an expired license file. Please detach the license file attached to this e-mail and place it in the following location:C:\Program Files\SID\Bin. Replace the existing file with this new file.
Note: This file should only be saved in the before mentioned directory. Attempting to open the file may result in an “invalid file format” message.
Please also note that if you loose that license file and request to replace it, it would incur a USD 500 fee to cover the time and administration costs.
If our contact information has changed, please transfer this e-mail to the correct person and kindly provide us with his/her name, e-mail and phone number, thank you!
Don't hesitate to contact us if you have further questions.
Best regards,"
Because of this huge text nothing happens. But if I make the text shorter then the code is working. My default email account is Lotus Notes. Please help me.
Looney
|
|
|
|
|
Please - don't repost the same question so quickly. This is a volunteer based forum, where people get to your messages in their own time.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
How would I end another process from a C# app?
I do not want to call Process.Kill() as I have code that needs to run when the ApplicationExit event fires. I do not have a MainWindow so I can't call Process.CloseMainWindow(). Does anyone have another suggestion that I have missed?
|
|
|
|
|
Have you thought of putting in a kill method in the other process that you could call via remoting?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I hadn't thought of that. I was hoping for a nice simple way like the CloseMainWindow() function that I might have missed but that is certainly an option. Thanks.
|
|
|
|
|
You could add a main form, and make it invisible.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|