But here is what often turns up in this forum: ![]() The effect I wanted was a gliding effect so I’d move the toolbar a couple of pixels and sleep for a few milliseconds, schieving exactly the effect I wanted. I’ve written over one hundred thousands lines of Dot net and have only used Sleep once. With a little added complexity much is gained. This way the process never goes to sleep and remains responsive to users and data. Private Sub CompletionRoutine(Wood1 as Wood) If Finshed then CompletionRoutine(wood1) else Tmr.Start ![]() ‘ From the data determine if we are finished Private Sub Tmr_Tick ( ByVal sender As Object, ByVal e As System.EventArgs) _ Wood1.Arg1 = ArgA ‘ pack up data to process (Context) Private Sub ProcessData(ArgA, Argb, ArgC) Tmr.interval = 250 ‘ one quarter of second interval Protected friend withevents tmr as new įorm1_load ( ByVal sender As Object, ByVal e As System.EventArgs) _ This discussion would not be meaningful without offering models for the proper way code deal with issues like these: There is no analogous state in Dot Net and hence other techniques are used. In other words, it’s the basic design for a server. This architecture is useful for a program that handles something and then goes back to sleep. ![]() The event could be a timer expiration or I/O completion etc. Such a program is immediately put to sleep and when there is the delivery of an asynchronous event, it’s processed and the process goes back to sleep. A process can wake up to handle asynchronous execution so you might see designs analogous to this: In other Operating systems there are states analogous to Sleep which is not as severe. Beyond the process put into sleep states inability to respond to low Level GUI messages, the process also cannot respond to timers. There is a strong desire on the part of the beginner to want to use sleep to manage basic design flaws which disables a programs ability to respond to internal messages and events. Often the new developer wants to wait on something and they call sleep and because the basic properties of a process have been altered, the new user see unexpected results. Symptoms will be controls not working and forms not updating. Fundamentally then, a basic principle of a windows environment is that it is event driven and sleep disables the ability to process any and all events. “Sleep” disables a process ability to respond to anything internally or externally for the duration of Sleep call. Often we see upset users who have strange problems who have just called Sleep. A basic property that is expected of a process is that it be able to send and receive these messages which enable Windows to work. Internally, transparent to basic developers there are message pumps for dispatching these messages to a users code and controls. Externally, a process needs to send and receive messages so that controls (including forms) can behave as expected. These aspects of a process are kept fairly transparent to a developer but a process has properties external and internal to it. ![]() A process is a contextual environment for a program and it will allow a program to call the things it needs to run. In Windows operating systems, when one runs a process, they are starting a process. First of all some background information is needed. I thought I’d start a thread on this with background as to why we say these things. First of all, I hope that everyone who is interested joins in this conversation especially SJ, Carsten, Spotty, Andreas and Nobugz.Įxperienced developers here often see new developers experiencing difficulty after calling Threading.Sleep and more experienced developers take issue with its use but rarely is there ever a comprehensive explanation for that.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |