|
pbraun wrote: Does the DB really need to be accessed each time through the loop?
Yes, it does. It accesses the DB seeking for some different info each time.
About doing all the DB access at once, I can see what do u mean, but does it really make a difference? I can split the loop into 2 loops(with the same lenght). the first one is to access the DB and the other to do the calculations.
pbraun wrote: Do the calculations and store them in a manner that is efficient for later DB access once the calculations have been finished
Actually, my calculations depends on the values retrieved from the DB, that is, I have to access the DB first, get some values, do calculations, have result and then next loop.
Also, the data in DB is never affected. This process only retrieves records.
I can simplfy the process as following:
<br />
for (int i=0; i<NUM ; ++i){<br />
<br />
"SELECT * FROM TABLE WHERE CONDITION";
<br />
while (reader->Read()){<br />
<br />
<br />
<br />
}<br />
<br />
reader->>Close();<br />
<br />
}<br />
<br />
|
|
|
|
|
Hmmm. From that description, it seems that it would be better to send one query to the DB that retrieves all of the necessary data from the DB, then do the processing (in your case, calculations).
It is my opinion, that the constant queries to the DB is costing you the time. Of course, you will then have the problem of memory management if your number of data becomes sizable. In that case, you may want to complicate your algorithm by reading in up to a predetermined number of records, doing some of the calculations, then reading in the next batch of records, and so on until finished. This will minimize the DB access.
Phil
|
|
|
|
|
pbraun wrote: it seems that it would be better to send one query to the DB that retrieves all of the necessary data from the DB, then do the processing (in your case, calculations).
I'm afraid that it is not possible in my case, my condition is already complex enough at each loop , also it depends on some data outside the loop ...
pbraun wrote: the constant queries to the DB is costing you the time
Yes, the queries are costing much of the time!
I would like to ask also does the .NET framework do anything behind the scene when a long operation is in run?
I have encountered a warning when "another" long operation was running:
The CLR has been unable to transition from COM context 0x1a2008 to COM context 0x1a2178 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
Thanks for your help Phil, I really appreciate it
|
|
|
|
|
Hello. I have a doubt about multi-threading, if it is or not the best way to achieve the following:
I have a server application that listens a port through a socket.
A client will send messages to that application (many messages).
Because the amount of messages is huge, the server application should only send each received message to another process (a thread?) that manages the message, and then go with the next message.
I want a limited number of threads, so the server app just looks for one that is free and send the message to it. Once the threads finish the work, they wait to be called by the server app.
Are threads the solution for that?
Regards,
Diego F.
|
|
|
|
|
This sounds like a good example of when to use MSMQ. The microsoft message queue allows you to put messages on the MSMQ and then you can have something like a window service that is listening to the queue. It will read the item from the queue process it and then get the next item on the queue. I would write it first without threading. If the performace is not good enough then you could look at using threads to help with the processing.
If you do use threads, you should use the thread pool and just keep track of how many threads in the pool you are using. There is a limit to the number of threads in the pool, but it would probably be a good idea to keep track of how many you are using and only use a few. Still try the solution without threads first.
Ben
|
|
|
|
|
Thank you. I did a first try with thread pool. The system will receive many messages through the socket (may be 500 per second), so I want the best performance.
Regards,
Diego F.
|
|
|
|
|
In that case the thread pool will limit your performance as many of the messages will not be processed due to the thread pool queue being full. But that also depends on how long it takes for the messages to be processed. Still, don't risk dropping messages because the thread pool queue is full. Your best bet is to use the MSMQ or write your own thread pool code. MSMQ is most likely the best bet.
Phil
|
|
|
|
|
Thank you for your advise. I'll try a second approach with MSMQ.
Regards,
Diego F.
|
|
|
|
|
Can anybody point me to a tutorial, or a page explaining how to ngen your assembly during install time?
I have an installer project and I would like to avoid an ugly command window popping up when I do an install that runs ngen on the asseblies that I have just installed.
This seems like it should be a common task so I am surprised I cant find any good tutorials on how to do it (all I can find are pages telling you to do it, but not explaining how).
Any guidance/suggestions would be much appreciated
Truly wise men don't play leap frog with Unicorns.
|
|
|
|
|
|
So are the steps listed in that article done from a batch file as a custom install step?
I tried playing with that on my development computer, and I don't notice any speed boost at all when I ngen the assembly ... is the native code stored in some other location that I need to launch instead of the old assembly?
Truly wise men don't play leap frog with Unicorns.
|
|
|
|
|
Hi,
when we set the backcolor of a panel to Transparent,it works but when we hover or put the panle on a TextBox the backcolor shows as Control BackColor and no more transparency is supported.
How can we enable the trasparency of the textbox?
thanks
|
|
|
|
|
Transparent isn't transparent. Setting the BackColor of a control to Transparent tells it to take on the background properties of its parent container. Controls sitting behind your Panel will NOT show through the panel.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Right,but id there any way to do what i want?
|
|
|
|
|
WPF (Windows Presentation Foundation).
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Not sure what you mean. What are you trying to achieve?
Maybe you want to send the Panel to the back? Or bring the TextBox to the front?
|
|
|
|
|
well,i have a textbox and i want to show something over it ,using label didn't solve my problem because when i put the label on the textbox,it covers textbox,although i have set the transparency of the label.I tried to use panel but it didn't work the same way.
Thanks
|
|
|
|
|
Recently I was read an article and got to know about Path class. Many could be know it but wanted to share with other who don't know.
PATH Class allows to get file path related information in string format. This is in System.IO namespace.
Some of the methods in this class are as given below:
* ChangeExtension: Allows you to change the file extension of a path string.
* Combines: Allows you to combine two path strings into one.
* GetDirectoryName: Returns the directory information included in a path string.
* GetExtension: Returns the extension included in a path string.
* GetFileName: Returns the file name and extension of a path string.
* GetFileNameWithoutExtension: Returns the file name without the extension for a path string.
* GetFullPath: Returns the absolute path for a path string.
* GetInvalidFileNameChars: Returns a character array containing the characters not allowed in file names.
* GetPathRoot: Returns the root directory information for a path string.
* GetRandomFileName: Returns a random file or folder name.
* GetTempFileName: A uniquely named, zero-byte temporary file is created with the full path returned.
* GetTempPath: The path to the system's temporary directory is returned.
* HasExtension: Determines if a path string contains an extension (true) or not (false).
* IsPathRooted: Gets a value indicating whether the specified path string contains absolute or relative path information.
Hope you find it useful
Regards,
Jaiprakash M Bankolli
jaiprakash.bankolli@gmail.com
http://jaiprakash.blog.com/
|
|
|
|
|
So what about this post is better than finding the very same information in the documentation on the Path class[^] in MSDN?
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
MSDN is always good to refer to at the end, My post was to bring Path class to the notice of those who didn't knew OK.
Regards,
Jaiprakash M Bankolli
jaiprakash.bankolli@gmail.com
http://jaiprakash.blog.com/
|
|
|
|
|
Jaiprakash M Bankolli wrote: MSDN is always good to refer to at the end
At the end?! It is usually the first place I check.
Jaiprakash M Bankolli wrote: My post was to bring Path class to the notice of those who didn't knew
Well, in a short time this post will fall off the first page of this forum. Also, people will be unlikely to be looking for it if they didn't know about it.
|
|
|
|
|
"Well, in a short time this post will fall off the first page of this forum. Also, people will be unlikely to be looking for it if they didn't know about it. "
I know it will fall off but those who read it I felt it is better to post it, You certainly can't talk about how people will behave ... You talk about yourself not for others !!
Regards,
Jaiprakash M Bankolli
jaiprakash.bankolli@gmail.com
http://jaiprakash.blog.com/
|
|
|
|
|
Jaiprakash M Bankolli wrote: I know it will fall off but those who read it I felt it is better to post it, You certainly can't talk about how people will behave ... You talk about yourself not for others !!
If you feel this, then write an article on it. Make it informative and interesting, and show some examples of it in action. As Colin pointed out, the message will move down the forum and in a couple of months you won't be able to find it.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Well that is a good suggestion, let me think about it. The only reason why i had refrained writting an article is because it is only one class .. just like this there are many many classes which should be put as awareness through a post .... but still let me think about it
Regards,
Jaiprakash M Bankolli
jaiprakash.bankolli@gmail.com
Blog: http://jaiprakash.blog.com/
Suggestions: http://jaitoimprove.blog.com/
|
|
|
|
|
If you're worried about it only being one class, why not work it into an article with the Directory and File classes. Aim for it being the definitive source on how to use these classes - I guarantee that you will learn a lot about them in the process of writing a good article on them.
Deja View - the feeling that you've seen this post before.
|
|
|
|