What's the easiest way to divide your data into equal-size pieces ?

Performance freak
Search for a command to run...

Performance freak
No comments yet. Be the first to comment.
When you use Response.Redirect with its second parameter set to true, it triggers a call to Response.End() Response.Redirect("Login.aspx"); // default is true Response.Redirect("Login.aspx", true); // same as above This causes AS...

Using ThreadPool.QueueUserWorkItem: Helps bypass limitations when trying to run async code inside IHttpModule. Does not interfere with the ASP.NET pipeline. Email sending does not block the main thread. Calling SendMailAsync().Wait() is safe here...

Introduction In SQL Server, the bit data type is used to store boolean values (0 for false, 1 for true). However, when working with SQL Server in a .NET application using Entity Framework or LINQ to SQL, the bit field is automatically converted to a ...

System.Threading.ThreadAbortException: Thread was being aborted. at System.Threading.Thread.AbortInternal() To avoid the ThreadAbortException error when using Response.Redirect, setting the second parameter to false is generally sufficient. However,...

In Visual Studio; Solution Explorer-Project-Properties-Application. Check "Auto-Generate binding redirects" When this is selected, versions are specified in the web.config file after the Nuget package updates. When is binding necessary? If there is...

You can split 150K data into 10K packets in just 40 ticks. This value was obtained on .NET4.8 (C# 7.3) on a personal computer. By the way there are 10,000 ticks in a millisecond.
You can use Parallel.For() or Parallel.Foreach() if you have million data. Parallel is defined in .Net 4.0 and above frameworks. ForEach loop runs on multiple threads and the processing takes place in a parallel manner.
List<String> list = new List<String>();
for (int i = 0; i < 150001; i++)
{
list.Add(i.ToString());
}
int chunkSize = 9999;
var numOfChunks = list.Count / chunkSize; // initial number of chunks
if (list.Count % chunkSize > 0) { numOfChunks++; } // add one chunk for remainder if there is a remainder
for (var i = 0; i <= numOfChunks; i++)
{
var chunk = list.Skip(i * chunkSize).Take(chunkSize);
// Do something with chunk, like writing to file
}