C # Console App Threading?

I am going to write a console application that will run once a week at 2 a.m. on a Sunday morning. He is going to query the SQL server database, then do some calculations and then write the results to a new database.

It processes hundreds of thousands of records, so it will take several hours to complete.

I am going to create a C # console application and use the window scheduler to start it.

My questions:

1) Do you think this is a good approach? 2) In the past, similar console applications set the processor to 100% while it continuously loops. Is there a good way to handle threads properly, etc.

Any advice before I start would be greatly appreciated.

T

+3
source share
4 answers

In general, this is a good approach, because he plans the processor and the process of intensive data processing at off-peak / weekend hours so that user access and application availability are not reduced. Only how much time might your workflow take into account? If it works after 30-40 hours, it may affect working hours on Monday.

, , . , , . , , .

+1

, , /, . , , .

, . /, , 1 . , / , , /.

, . , .

0

Tasks.Parallel ( ). . , ...

0

If your processor is at 100%, you should use paging and batch processing to minimize the work your application does in each cycle. For example, instead of extracting all records from the database, select the first million, process it, and then select the next million, etc.

If one thread consumes all CPU cycles, creating multiple threads will only add overhead.

0
source

Source: https://habr.com/ru/post/1766180/


All Articles