Silk Yarn (3538527583)

Reader Tyler shares this outstanding example of thread evasion:

Apparently they needed a way to delay current execution but still process window messages, and running it in a separate Thread and calling Sleep() would have been too hard ... Thankfully this function isn't actually being used anymore, and has been canned from the repo.

Thankfully, indeed. Come for the honest commenting, stay for the funky definition of one second, the adding of seconds that I think is supposed to represent real time ticking by as the function runs, the countup (countdowns are lame), and the invocation of Application.DoEvents(), a holdover from Visual Basic. Seeing as this is a VB.NET app, it's probably not the best way to allow other processes and events to run, but there are differing opinions on this.

    ''NEVER USE THIS FUNCTION, it is full of evil and it will come to haunt you.... 
    Public Shared Sub Delay(ByVal dblSecs As Double)
        Const OneSec As Double = 1.0# / (1440.0# * 60.0#)
        Dim dblWaitTil As Date
        dblWaitTil = Now.AddSeconds(OneSec).AddSeconds(dblSecs)
        Do Until Now > dblWaitTil
            Application.DoEvents() ' Allow windows messages to be processed
    End Sub

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!