|
Hi, I am developing a live support application operator console using .net windows forms. Now in this application it's very important to show the current info in fastest way. I am showing all the users on site in a list-view control and to show the updated status of online users I am refreshing the list-view control's content by every second. Now when user will click on any listview record, it will show the details of user ( chat script, geographical info,navigation info) in the bellowed panel. It works quite fast when it is on my machine. But when I m using the remote database it's TOO SLOW :(. Now , 1. What I can do to improve performance ? 2. Shall I go for threading ? I tried to use use threading like private void timer_refresh_Tick(object sender, EventArgs e) { Thread _timerTickOp = new Thread(TimerTickOperations); _timerTickOp.Start(); } private void TimerTickOperations() { try { UserFacade facade = new UserFacade(); Operators _currentOperator = facade.GetOperator(LoginForm.LoggedInOperatorName); FillUsers(toolStripCbox_Filter.SelectedIndex); ..... } but I m getting err 'Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on.' What should I do to improve performance? - Changed TypeAland LiMSFT, ModeratorTuesday, September 22, 2009 10:05 AMNo reply
-
| | Tejaswini Prashant J Tuesday, September 15, 2009 6:09 AM | There is no use in using threading. As you already say, the software works great on your local machine, so this is not a threading or CPU performance issue. The remote database (or the connection to the database) is too slow. So speed up your internet (or network) connection or improve the computer the remote database is running on.
Geert van Horrik - CatenaLogic
Visit my blog: http://blog.catenalogic.com
Looking for a way to deploy your updates to all your clients? Try Updater! | | Geert van Horrik Tuesday, September 15, 2009 7:17 AM | The remote db is not slow.. coz it's well working with a web application. | | Tejaswini Prashant J Tuesday, September 15, 2009 7:34 AM | Hi Tejaswini,
How do you connect to database remotely, .Net remoting, web service or WCF? What protocol do you select, tcp or http? If the performance is high in web application, you need to use http protocol, such as web service to connect to the database.
Regards, Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread. | | Aland Li Wednesday, September 16, 2009 10:31 AM | Hi Aland, This is my first windows application.. so u can say I am very new to this.. I m connecting normally to the database ..so If I m nt wrong it will use Http protocol to connect(is it?) my connection string is connectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=xx.xx.xx.xx;PORT=3306;DATABASE=myDatabaset;UID=userid;PWD=pwdsupp;OPTION=3"; Shall I go for windows service ? How I can use Http protocol to connect to remote Database? Can you guide me .. Your guidance will help me a lot ... Thanks in advance :) | | Tejaswini Prashant J Thursday, September 17, 2009 4:42 AM | Hi Tejaswini Prashant J,
Sorry for the misunderstanding, I thought the client connects to a server, then the server connects to the database. Based on my understanding, if the application directly connects to the database, the low performance ought not be caused by the network. The cause can be among the items below:
1. The application connects to the database too frequently. In other words, there are too many connections opened and then closed in a short time. In this case, we can create a connection pooling to improve the performance.
This is a simple instruction of connection pooling: http://msdn.microsoft.com/en-us/library/aa719769(VS.71).aspx.
This is a sample project about connection pooling: http://www.codeproject.com/KB/dotnet/ADONET_ConnectionPooling.aspx?msg=2357540.
2. The UI logic is implemented improperly. For example, a table has 1,000,000 records, we only need to show some of them, but the application load all the records and bind the table to a DataGridView. This would have the form load very slowly.
Before modifying the code, you need to trace the program executing to know which part of your program leads to the low performance. You can read this article to get some ideas: http://support.microsoft.com/default.aspx/kb/815788.
Let me know if this does not help. Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread. | | Aland Li Thursday, September 17, 2009 5:03 AM | Hey Hi Aland, First of all I m very thankful to u, as ur replies are always like Oasis or a ray of Hopes and possibilities for me :) Back to my technical issue.. the 2nd point I have worked properly... but you are absolutely right on 1st point and that I got to know yesterday only.. I was opening conenction for every request so there was 6 to 7 connections at database side..which was one of the big cause to slow down my application... I started working on it .. and as per my scenario..I will open the connection when application will start , and will reopen it if it;s closed/Broken by any chance. (If you want any correction in this plz let me knw). Thanks for the connection pool tip...that I was not knowing.. But I am using MyODBC 3.51 to connect to Mysql.. can I use connection pooling in that case.. (as I searched now it not support connection pooling :( ) and if yes.. How I can do that? And if it's not providing How I can connect to mySql Databse? (Shall I go for Connector/Net 6.1 or anything else you will suggest?)
| | Tejaswini Prashant J Thursday, September 17, 2009 5:34 AM | Hi Tejaswini Prashant J,
The article below shows odbc pooling: http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q164221. Have you trace the UI loading time. We need to decide if the data loading or the UI loading costs most of the time. We can use DateTime to get the executing time of a piece of code as follows: DateTime dt = DateTime.Now; //Execute some code TimeSpan executingTime = DateTime.Now - dt; If we can make sure the data loading costs most of the time,we can trace the connections opened and closed. If there are too many connections, we can use the pooling to improve the performance. You said there are 6 or 7 connections in the server side. From my experience, it is legal and will not cause the low performance. Could you please provide more information about the type and count of records those are loaded to the data base and how you bind them to the UI? Regards, Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread. | | Aland Li Thursday, September 17, 2009 5:56 AM | Hi Aland Li, I am showing 100 to 200 records per Listview /GridView. But now Performance issue is occurring I think because I am refreshing Data after every 1/2 seconds. And after every 1/2 seconds I m reconnecting to remote db. So I thnk I will catch the records using Catch Manager now.. Do u think it will help me to improve performance?
| | Tejaswini Prashant J Friday, September 18, 2009 4:36 AM | Hi Tejaswini Prashant J,
I understand your idea, but we'd better decide if the database operation really cost the most of the time. We need to know the exact executing time of some code and compare them to decide which part costs too much time.
I have developed a project in the last year, in which I also met a performance issue. Since I used lots of reflection code in that module, so I think this costs most of the time. But when I trace the executing time of the code and compare them, I found the object-relation mapping part costs most of the time.
It is hard to decide which part cause the low performance only based our experience. We'd bettercollect the exact performance data before we made any decisions.
Let me know if you are not clear about my ideas. Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread. | | Aland Li Friday, September 18, 2009 4:44 AM | Hi,
We are changing the issue type to “General Discussion�because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question�by opening the Options list at the top of the post window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread. | | Aland Li Tuesday, September 22, 2009 10:05 AM |
|