|
The first obviouse thing is:
while (html_sr.Peek() >=0)
{
txt_file = html_sr.ReadLine();
Why not use:
while((txt_file = html_sr.ReadLine()) != null)
{
}
Now, you no longer have to perform the peek operation and your test is against a value you would get anyway. (Since the RealLine method already performs some operation to determine whether it is at the EOF why duplicate the effort)
EuroCPian Spring 2004 Get Together[^]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
"Get in touch with your Inner Capitalist - I wish you much success!" -- Christopher Duncan, Lounge 9-Feb-2004
|
|
|
|
|
Thanks!
i had thought that Readline would throw an exception
now to test and see if this will provide any performance improvement
though i suppose most of my problem is the SQL method...
right now it proceses on average 170 of those lines per second, just trying to squash it down as much as possible
|
|
|
|
|
You should probably use some profiler to see what takes most time.
It probably is sql query. Make sure you're not opening the connection with each query, but open it once and do all the queries then.
|
|
|
|
|
thanks...
the query is actually a single stored procedure, but a complex one
|
|
|
|
|
If you're doing INSERTs on a SQL Server from a comma-delimited file, use BCP (Bulk Copy).
It can do up to 100,000 lines/second on a big machine and on desktop machines it processes up to 10,000 lines/second.
Perl combines all the worst aspects of C and Lisp: a billion different sublanguages in one monolithic executable. It combines the power of C with the readability of PostScript. -- Jamie Zawinski
|
|
|
|
|
unfortunatly the text file needs to be "processed"
|
|
|
|
|
Hi there
How can i restrict the appearance of child forms?
i only want 1 instance of a particular child form
how do i do that?
VisionTec
|
|
|
|
|
visiontec wrote:
How can i restrict the appearance of child forms?
This is ambiguous. Appearance in this context could mean the number of times it appears or the way it looks.
visiontec wrote:
i only want 1 instance of a particular child form
how do i do that?
Apply the singleton pattern to it. Actually, I'm not too sure whether that is completely wise or not in the context of a form. If your not already aware, a "singleton" is a class that only ever has one instance in existance at any time (some more strickter definitions might even say only one instance ever). This is acomplished by making the constructor private, creating static field of the class type and creating a static method that creates the one and only instance or returns the existing instance. If you need to know more about singletons just ask and I, or someone else, will help you out.
EuroCPian Spring 2004 Get Together[^]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
"Get in touch with your Inner Capitalist - I wish you much success!" -- Christopher Duncan, Lounge 9-Feb-2004
|
|
|
|
|
Hi there
In my mdi app i have a child form which has a tabcontrol on it.
there r 2 pages in that tabcontrol
Now how can i load the child form to show
the start page that i want?
VisionTec
|
|
|
|
|
You could pass an int to the child form's constructor, and in the constructor set TabControl.SelectedIndex to that int , or do this using the set accessor of a property of your child form, or many other ways. This is a simple object-oriented design (heck, even procedural designs would be simple).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I am very familiar with DCOM and its inner-workings, but this is my first attempt at doing something with C#.
I want to write a windows service in C# that a ASP.NET webapp or C# application can talk to as a client. The client would have to pass several pieces of information to the service and exit. The service will add the request into a queue and then process it as its leisure. The service will post the results of the request to a ftp site for user's to download. So there is nothing syncronous about this operation. The client does not wait around for the results.
Should I be using .NET remoting to talk to the windows service? If so, should the remoted object be a singleton or a single call? Should the service implement its own queue/thread mechanism, or use the built-in thread-pooling to handle the request queue?
Any ideas/suggestions would be helpful.
Thanks in advance,
Kevin
|
|
|
|
|
Kevin Tambascio wrote:
Should I be using .NET remoting to talk to the windows service?
Yup. It's really straight forward to set up what you want to do.
Kevin Tambascio wrote:
If so, should the remoted object be a singleton or a single call?
I prefer the singleton mode because I can make multiple calls on the same instance rather than a new instance.
Kevin Tambascio wrote:
Should the service implement its own queue/thread mechanism, or use the built-in thread-pooling to handle the request queue?
As for this, read my article on .NET's built in threadpooling. http://www.codeproject.com/csharp/threadtests.asp[^] It's intended to service threads that are mostly asleep and do their thing quickly. I'd probably suggest Stephan Stoub's thread pool manager, which you can download from the article.
Hope that helps!
Marc
Latest AAL Article
My blog
Join my forum!
|
|
|
|
|
Marc,
Thanks for your help, I hope you won't mind a few more questions.
I got .NET remoting to work between two .exe's, seems very nice so far. If I create the remote object as a singleton (using multiple clients), will functions in that remote object be called from one thread in some order, or just called all at once? Do I have to synchronize those calls to shared objects?
Also, this service will eventually be called from a web app (ASP.NET) instead of a exe. Will each user's instance of the website be able to create a TcpChannel at the same port number to talk to the remote object, or will each of the client's have to have some knowledge of each other to find a unused port number to create that TcpChannel?
Thanks again,
Kevin
|
|
|
|
|
Kevin Tambascio wrote:
If I create the remote object as a singleton (using multiple clients), will functions in that remote object be called from one thread in some order, or just called all at once? Do I have to synchronize those calls to shared objects?
Honestly, I don't have a positive answer for that. However, since each instance gets its own AppDomain, I think that there would be multiple instances. I can't imagine it otherwise, actually. So I think you'll have to deal with synchronization yourself.
Kevin Tambascio wrote:
Also, this service will eventually be called from a web app (ASP.NET) instead of a exe.
Hmmm. You mean, on the client side? I don't think you can do that. That's what web services / SOAP is for, I think (again, i'm fuzzy on that).
Kevin Tambascio wrote:
Will each user's instance of the website be able to create a TcpChannel at the same port number to talk to the remote object,
My understanding is yes--the same port number is used. For example, I've been able to connect to my remote object from two different computers on my local network using the same port number. I *believe* that the initial port number is just for saying "hello", and then an unused port number is negotiated. I could be totally wrong though.
Sorry these answers are full of "I'm not sure". If you find out more, It would be great if you could let me know!
Marc
Latest AAL Article
My blog
Join my forum!
|
|
|
|
|
Marc,
Found an interesting article here: http://builder.com.com/5100-6389-5034970.html
Seems like I can use .NET remoting. The webserver and windows service will be on the same machine. So I can technically use either, but performance will be better with straight remoting. In the future, I could also create a .NET client app that people could run from behind firewalls and use SOAP/Web Service, but that is down the road. I think I'm going to write some code to try and access my service from a web page and see how far I can get.
Thanks for your help,
Kevin
|
|
|
|
|
Hi all,
I'm working with Shellnotifications...
(http://www.codeproject.com/csharp/shellnotifications.asp?target=Shellnotifications)
I want to read out the InternetExplorer History Notifications.
I've changed the Register Event to CSIDL_HISTORY but it didn't work correctly.
If I click on an IE link, nothing happens.
I have seen it working in a vb project.
(http://vbnet.mvps.org/index.html?code/shell/shchangenotify.htm)
Somebody got a solution? ![Sigh | :sigh:](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_sigh.gif)
|
|
|
|
|
Yeah, correctly translate the VB code or ask in the forum in the Shell Notications article. That's why article forums are provided.
While language syntax may be different, the InternetExplorer out-of-process server is a COM automation server and can be accessed the same by any COM-compatible framework, like the .NET Framework. It will work if you define everything correctly (such as P/Invoking any required functions, declaring constants, etc.).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How can i animate listView items icons???
ImageAnimator has no affect on them.
|
|
|
|
|
The List View common control - which the ListView Windows Forms control encapsulates, does not support animation (and why should it?). If you want to animate these, you'll have to extend ListView , override WndProc , and handle all the item painting (for an icon, for instance) yourself. These notification messages are documented in the Platform SDK under the UI section. See http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/listview/reflist.asp[^] for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
string code = "05";
string str;
I want the string str as follows = "05" in that case the double quotes makes part of the sting.
I tried as follows :
str= "\"" + code + "\"";
I receive following (when I stand on str) --> "\"05\""
I tried also :
str = @"""" + code + @"""";
I receive following (when I stand on str) --> "\"05\""
How I can slove this?
Thx,
Jac
|
|
|
|
|
Your code is correct, the debugger displays the \-character just for your information
To see the correct value of "str", use Console.WriteLine(str);
|
|
|
|
|
As an off-topic note, do not concatentate strings like that. Any knowledge of characters arrays would tell you that string concatenations are a (m-1)O(2n) operation, where n is the number of characters and m is the number of strings. Strings are immutable and require that a string long enough for the the first two operands be created (which requires parsing the length of each string), and then characters are copied one-by-one into each. Then this repeats for each string.
Instead, use String.Concat for up to 4 strings, or use String.Format , which provides additional formatting facilities. In your case, the following expression would work well:
string str = string.Format("\"{0}\"", code);
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Dear all,
I have a big problem with datasets in c#. The problem that I have a huge data size which I have to locate it in the dataset (about 80500 records which joined to 100000 records in other table-master detail dataset-) and when I do that I have a problem with accessing the dataset with this amount of data
I have create a dataset with tow data tables and create a relation between the tow data tables
If any body knows any thing which can help with this problem could you please help me with it?
Thanks a lot
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
Can't you load only part of data that you need at a time? Or you can use connected way instead of disconnected way, not sure if this has better perfomance.
Mazy
You're face to face,
With the man who sold the world - David Bowie
|
|
|
|
|
Sorry Mazdak ,
but in my application i ahve to use all theis data in the same time so i have to load all data to the dataset
Mhmoud Rawas
------------
Software Eng.
|
|
|
|