开发者

Why console application is taking more time than forms application in c#

I have created a Class Library (called as GNGEngine.dll) which performs some image processing stuff. This dll contains a function ProcessBitmap() as the main function to do searching for specific pattern. I have tested the engine by creating anothers forms application and taking the reference of the dll. I am calling the ProcessBi开发者_如何学Ctmap() method of dll by clicking on the button. The forms application takes 8secs to process the image completely.

Now as per clients requirement i have created an exe (console application) file GNGEngineRunner.exe which takes the image filename as the argument. I have created the object of dll class and called the method ProcessBitmap() and passed the file for its processing. The same image now takes almost a minute to its processing.

Is there any specific reason, why it is taking too much time?

Thanks for sharing your valuable time.


First of all you should attach a profiler to see what is happening. If you don't have one you can use the trial version at http://www.red-gate.com/products/dotnet-development/ants-performance-profiler/

Visual Studio has a performance profiler built in, but depending on your VS version it could be anything from nonexistant, crappy or good.

Second, there should be no reason for this. I would guess that the problem is that you have exceptions being thrown because of reference to a non-existing form/GUI-object or similar. Execution-wise Console or WinForm is 100% the same and you can even mix them in one app. The only difference is some references and the fact that you create a console window instead of a form.

Feel free to add more details and possibly some code.


You haven't told us what you're doing or how you're doing it, which makes it near impossible to answer really... but your first step should be to get some appropriate traces of what's going on. Insert a judicious amount of logging (including a timestamp) and then it should be reasonably clear where in your process the time is going. Run it in both the console version and the Windows Forms version. Then concentrate on the bottleneck - possibly asking another SO question with more details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜