I'm trying to optimize some code that I've written and I've come across a style that I use ~20 or times that will be run ~100 or so times during the full execution of my code(a VSTO excel spreadsheet).
I was wondering whether using something like this would make any difference
form.attribute = complicated boolean statement.
Could eliminating the if/else actually noticably speed up my code, or is this change so insignificant that I shoul concentrate on some of the other pieces of code to eliminate database calls and recomputation when it isn't necessary?
The difference in performance is so very small that it's more a matter of taste and style.
The second code is a bit more efficient, mainly because it doesn't contain a jump. If you only run the code a hundred times though, the difference in execution time is so small that it's not even possible to measure.
my problem comes from the fact that I'm trying to make my progressbar progress while I'm scanning directory files.the awk thing is that my scan function is defined within my datalayer as a dll.I want my progress bar to follow the files processing. I first thought about threads but could'nt move on.probably got allergy for threads.can anybody help?
thanks in advance
If you have "access" to the source of the datalayer dll you could create some events. You can trap these events in your app then, like what the WebBrowser does with it's DocumentProgress (or something like that) event.
Your problem seems to be a perfect candidate for the BackgroundWroker thread control that's newly available in the .NET 2.0 framework.
Using this controll is rather pain free. It's literally a matter of a few click to get yourself set up with a background worker thread that is going ot perform the scan in background for you. The way you use this control is you have to provide three functions to handle three events. One is the actual worker function (this will be the function that scans the files). Then There is a function that will be called when the progress changes. And the last one is going to be a function that will be called when the thread ahs finished processing. So in the actual worker function you will need to call the ReportProgress function that will basically marshal your call and eventually fire the second event (the progress changed event) on the appropriate thread. It's that easy.
Feel free to google for the BackgroundWorkerThread samples online
I'm trying to print a document with a right-to-left language. I want to use the drawString() method, but it flips special signs like "." and "!" etc. just like in every other place in windows using this language (and left-to-right mode).
my question is, is there a right-to-left drawString()? or a way to turn this method into right-to-left?
my current solution is using drawString char-by-char using a method I wrote, but it seems like "Bad Programming" and very unefficient.
Could someone please tell me what is the best way to late bind to COM dlls? I'm basically developing an application that loads specified dlls and then runs certain functions contained in those dlls. The problem is that I don't know the libraries to load until runtime, so I can't really use tlbimp. I know it is possible to use tlbimp at runtime (using TypeLibConverter) but this creates new names for the functions in the dll, so it may not be such a good idea...