|
-
December 26th, 2009, 12:33 PM
#23
Re: Looking to develope skills
 Originally Posted by Dragster93
I did that because otherwise, it would say, can't implicitely convert DateTime to Int.
You need to understand what DateTime.Now does. It makes an instance of the DateTime class and sets it to the current time. When you call Datetime.Now.Year, you are accessing the year property of the current date time instance. Since the Year property is declared as an integer, you don't need to convert it.
 Originally Posted by Dragster93
So what you're saying is that I should store the DateTime value in a variable and then use that variable rather than calling DateTime() everytime???
Yes. Everytime you call DateTime.Now you are creating a separate datetime instance. Just call it once.
 Originally Posted by Dragster93
Yes, I understood why it's freezing, that is why I tried to use the backgroundworker to do the calcuation in background. But I seem to be having a little trouble with it. I use 'backgroundworker.dispose()' to free the resources so that if the Set Alarm button is clicked a second time to set a different time, the it shouldn't display an exception saying, "The thread is busy". But that seems to work only for the second click. If you click the third time, again the same problem occurs. I shall try using the catch and throw exception for that problem and see if it works
You have something wrong with the background worker code. Post your background worker code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|