Solved

How to rework my C# console application code so that it writes out records on a more timely basis?

Posted on 2014-01-27
1
351 Views
Last Modified: 2014-02-03
I am writing a C# console application using VS2010 that reads a check image file comprised of a combination of binary and text data and writes out 3 files.

The application writes out records very slowly. I was wondering if you could suggest alternate code to make it run faster. It only writes out about 2 records per minute to the file with the file extension "ard.out".

My code is attached.
BankCheckImage.txt
0
Comment
Question by:zimmer9
1 Comment
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 500 total points
ID: 39813069
Not sure how significant this is, but you seem to do a LOT of needless skipping...

In the

for (int i = 0; i < bytes.Length; i++)

loop, you skip 0 bytes at
var data = bytes.Skip(i).Take(anchor1.Length);
the first time, then 1, then 2....etc.  If bytes.Length is large, this could involve a LOT of repeated skipping, when you could have done (initially set restBytes = bytes)

var data = restBytes.Take(anchor1.Length);

....
....
....
stuff
....

restBytes = restBytes.Skip(1);

where you never have to skip more than one item per loop.

There are other instances in your code of the same construct.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now