How can I make my application run faster [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm building a windows forms application, and I'm processing a huge database, so I have to use many loops to work with my tables.
I'm using C# language, the problem is when the program process data the application lag during the processing and the time require to process my data is not acceptable.

Well if you are using C# language,
First to prevent the lag issue; use a Task:
Task task = Task.Factory.StartNew(() =>
{
//put your code here
});
and for loops you can use Parallel class it has for and foreach.
if you need to modify something in the GUI you can use the following code:
this.Invoke((MethodInvoker)delegate
{
//your code
});
and there are other ways by creating threads or backgroud workers...

Try to process your Data in Sql server using stored procedure, views.
Try to use multithreading.
get your data filterd and paged from data base.
Optimize your tables using indexes.

Related

service in c# to connect to sql , [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have a database, and I need to write in c# a script to execute some statements and save the result of these statements to another database, and each statement has a condition like run daily or weekly.
Then I need to save this script like a service in the window server to run it automatically.
so 1 service, for many statements, and each statement has condition inside the service.
any suggestions, or examples for this scenario?
thank you
There are multiple options:
Write your code in a console application and convert it to a windows server. If you write the code perfectly and create some timer or or function to handle the jobs they whould be run exactly at the desired time. Manual here
Using windows task scheduler for each job and create a scheduler for them. For example if you have 3 jobs (hourly,daily and weekly) you can create three separated console application and create 3 scheduled jobs in windows task scheduler. Here you have a log of last execution time, the result, the erorr etc... More info here

Refreshing data periodically using SignalR rather than broadcasting to clients [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I display some of the data i.e. Sum, Average and Total on a page and want to update them after the data changed using SignalR. Most of the examples uses the following approach that broadcast all of the clients after create / update / delete methods (that change data) are executed:
private void BroadcastDataChange(Data data)
{
Clients.All.dataChanged();
}
However, I am wondering if there is a smarter approach that let me update the data i.e. periodically refreshing without broadcast in each of the create-update-delete methods (I do not use SqlDependency, etc, juts using SignalR). On the other hand, I am not sure this kind of approach is contradictory to the SignalR logic. This is the first time I use SÄ°gnalR and I am too confused :( Any help would be appreciated.
You can use polling with SignalR. It's just an inefficient way of doing things though, because: (1) there would be a delay between when changes happen and when they are broadcast to clients. (2) broadcasts would happen even if data didn't change, which is a waste of resources.

Group Box in different Thread [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have 5 Group Box in my software I want to run them differently for example I have one group box which takes lot of time around 20-30 minutes till then my software hangs. SO I want to make other functionality working when a particular group box is working any solution for it?
Group boxes don't "work". If they're just some GUI for a resource intensive task, you probably want to run that task asynchronously (or multi-threaded, depending on your requirements) and only use the GUI for settings / updates / whatever. The key is to never do much work on the GUI thread - if a GUI action takes more than say 50-100ms, it should probably be done elsewhere. Note that using await makes this very easy to do properly - if that's not available, a BackgroundWorker is probably the best option. Do note it doesn't shield you from synchronization issues, though!

how to pre load a read only database in asp.net [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have used fastcgi when a process starts up and then executes and serves results to a client. I used to preload a readonly database into memory during the start up and then use that to server results. The advantage being the data gets loaded and prepared only once and is readily available.
How can this be accomplished in ASP.NET technology without using an external database technology like memcached etc?
It depends on how complicated the database is, but if I needed to do this I would load the database into the application cache as datatables, within the global.asax application_startup method.

Multithreading advice on approach needed [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have been told to make a process that insert data for clients using multithreading.
Need to update a client database in a short period of time.There is an application that does the job but it's single threaded.Need to make it multithread.
The idea being is to insert data in batches using the existing application
EG
Process 50000 records
assign 5000 record to each thread
The idea is to fire 10-20 threads and even multiple instance of the same application to do the job.
Any ideas,suggestions examples how to approach this.
It's .net 2.0 unfortunately.
Are there any good example how to do it that you have come across,EG ThreadPool etc.
Reading on multithreading in the meantime
I'll bet dollars to donuts the problem is that the existing code just uses an absurdly inefficient algorithm. Making it multi-threaded won't help unless you fix the algorithm too. And if you fix the algorithm, it likely will not need to be multi-threaded. This doesn't sound like the type of problem that typically benefits from multi-threading itself.
The only possible scenario I could see where this matters is if latency to the database is an issue. But if it's on the same LAN or in the same datacenter, that won't be an issue.

Categories