New answers tagged

1

If your create a fourth lib and use project references, you will not get the desired result, that way a consumer of that lib will still need to reference all the libs individually. However, at least you can put the initialization code in that fourth lib. Your first alternative will most probably work well when you still keep each of the current libs in its ...


-1

Doesn't sound like you need a timer. Here is some code that shows an alternative. First the replacement code for the timer. Public Sub TimerReplacement() Do doit.WaitOne() If isrun.WaitOne(0) Then 'code here Stop Else Exit Do End If Loop Debug.WriteLine("END") End Sub Some ...


3

I am confident enough that unless I let a = true, it will disregard the tick event. No, it won't. The line won't be written to the console, but Timer1_Tick will be called and the condition will be evaluated. In terms of performance, it won't matter much in most cases: otherwise, you'll see its effects when profiling your application. On the other hand, ...


4

Coming from an embedded development background, I think it's generally a good idea to free unused resources. This still holds true for current environments and systems, how powerful they may be - a resource not allocated is one you can use elsewhere (in this case, as pointed out above, CPU cycles and battery power). And of course there are exceptions to the ...


8

Depends. How many timers, how often, what environment. If you run a timer pointlessly sixty times a second on an iPhone, you are wasting significant amounts of energy and reduce the battery life, because every time the timer runs the CPU has to go up from sleep to full speed and back again, which is very expensive, if you do it sixty times per second. If you ...


3

One solution is to not give the derived class a choice by having a non-virtual method in the base class and also a virtual empty method, which is called from the non-virtual method at the right time. The code for the two cases could look like this: class Base { public void BaseBeforeDerived() { // do base work here ...



Top 50 recent answers are included