|
Replace tmNow with DateTime.Now...
And people are here to help, not to do the work for you. I shall explain how the above method works, so that you can use it / write up your own.
It gets the current time using DateTime.Now and stores it, and the next time the method is called it compares this with the new current time through use of a TimeSpan, wich is quite self explanatory. So the time since the method was last called is DateTime.Now - thatOtherTimeFromBefore
It then compares the minutes property of the TimeSpan, to the int you provided to the method (which is the number of minutes you want to check have passed). Thats pretty much just an if statement.
It then returns true if the minutes property is greater than, or equal to, your int; and false if it is not.
----
And if i am mistaken, i apologise. I'm leaving now...
My current favourite word is: PIE!
Good ol' pie, it's been a while.
|
|
|
|
|
Kristian Sixhoej wrote: show me how to use this?
I've provided you with a ready-to-use method to check if "x" minutes have expired since the last check. If you're not sure how or where to call this method, then I suggest you spend some time familiarizing yourself with the basic concepts of control flow and method calls in C# before attempting to build your solution.
Kristian Sixhoej wrote: By the way, Visual Studio complains about that tmNow doesn't exist in the current context.
That's because I made a typo (now corrected in my original reply). Again, your inability to spot and correct my error leads me to believe you're probably better off spending some time going over the basics of C# before crafting a solution to your problem.
I hope you don't misinterpret my comments - I just feel you may have bitten off more than you can chew at this point in time.
/ravi
|
|
|
|
|
I *am* actually familar with C# and method calling, etc etc.
Ravi Bhavnani wrote: Again, your inability to spot and correct my error..
In fact, I *did* spot the error and corrected it.
Anyways, what I've done is, I've pasted the method you provided outside my Main-method, but it doesn't work. It gives me this error when I try to build:
The name 'lastTimeCommandWasUsed' does not exist in the current context.
If I'm not mistaken, this must be assigned a value whenever the command is executed, right? But then your method won't be able to find it, since it's within a scope. Please correct me if I am wrong.
Kristian Sixhoej
"Failure is not an option" - Gene Kranz
|
|
|
|
|
Kristian Sixhoej wrote: In fact, I *did* spot the error and corrected it.
OK. That wasn't evident from your post.
Kristian Sixhoej wrote: The name 'lastTimeCommandWasUsed' does not exist in the current context.
You may want to encapsulate the check for elapsed time in a class (eg: ElapsedTimeChecker ) that has (a) a static member lastTimeCommandWasUsed (static preserves its value across calls) and (b) a public static method CheckIfXMinutesElapsed() as shown earlier. Then just call that method when you're about to perform the code you want to execute every 3 minutes, by doing this:
if (ElapsedTimeChecker.CheckIfXMinutesHaveElapsed (3))
doSomething();
else
sorryYouMustWaitAtLeastThreeMinutes();
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: OK. That wasn't evident from your post.
Nah, I know. I just needed to think twice.
Let's leave that for now.
I will try your suggestion in a little while.
Anyways, thanks.
Kristian Sixhoej
"Failure is not an option" - Gene Kranz
|
|
|
|
|
Ravi Bhavnani wrote: You may want to encapsulate the check for elapsed time in a class (eg: ElapsedTimeChecker) ...
I've done that, and it works perfectly now. Thanks a lot.
I didn't expect this to be so "advanced"
Anyways, thanks again.
Kristian Sixhoej
"Failure is not an option" - Gene Kranz
|
|
|
|
|
Excellent - glad you're up and running!
/ravi
|
|
|
|
|
Could anyone please post some code for a simple sound to play that everyone has using DirectSound? (When adding reference, please tell me which version if you decide to do this.) Thanks.
- I love D-flat!
|
|
|
|
|
Have you installed the latest DirectX SDK? If so you'll find an application called DirectX Sample Browser which has a PlaySound sample application you can install and play with.
"On one of my cards it said I had to find temperatures lower than -8. The numbers I uncovered were -6 and -7 so I thought I had won, and so did the woman in the shop. But when she scanned the card the machine said I hadn't.
"I phoned Camelot and they fobbed me off with some story that -6 is higher - not lower - than -8 but I'm not having it."
-Tina Farrell, a 23 year old thicky from Levenshulme, Manchester.
|
|
|
|
|
I went through it, and it was a sound application, but in the source, all I found was Direct3D things, honestly. Should I feel like an idiot? (No smart comments) PLEASE HELP!
-- modified at 13:17 Sunday 25th November, 2007
- I love D-flat!
|
|
|
|
|
hi
I will protected all file in a directory but I don't know about it
plzzzzzz help me if you have a solution
thanks alot
regard
|
|
|
|
|
You have to be a bit more specific. Whom and what is it that you want to protect the files from?
By the way, your zzzzzzzzzz key zzzzzzzzzemzzzzzzzzzzzz to be zzzzzzzzzzzzzztuck...
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Guffa wrote: your zzzzzzzzzz key zzzzzzzzzemzzzzzzzzzzzz to be zzzzzzzzzzzzzztuck...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Guffa wrote: By the way, your zzzzzzzzzz key zzzzzzzzzemzzzzzzzzzzzz to be zzzzzzzzzzzzzztuck...
It seems your keyboard driver is written in Lisp
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Eg. I want to add user to System.Window.Forms.LinkView.
It will show all user being added in.
& i want to add certain user to System.Window.Forms.Listbox.
Is this possible work?
|
|
|
|
|
What's a System.Window.Forms.LinkView ?
/ravi
|
|
|
|
|
i want to get data in LinkView via arrow button and show it in the listbox
|
|
|
|
|
Hey.
By spying on windows in IE and IE7 i've managed to retrieve the URL
to my application using FindWindowEx and SendMessage API.
The thing is, now i would like to retrive them from Firefox and Opera browser aswell. When looking at Internet Explorer on a spy tool i can see all the controls, For instance, a TabControl, in that TabControl
there is something called ReBarWindow and in that i can see that there is some ComboBoxes and in those there's an Edit field (Textbox).
And thereby i can grab the handle of that control and do what i please.
In Firefox or Opera for that matter there are only 3 "windows" and all sub-windows have exactly the same name, and there is no way to tell WHAT is What?
So, what i basically need is a handle to the combobox in firefox, which for me atleast seems to be invinsible..?
I need help on this, i hope i explained well.
|
|
|
|
|
My timer callback delegate may decide to dispose the timer if certain conditions are true.
Do i need to lock(this) before doing so since another callback may be executed at the same time?
thanks alot !!
more details if you have the time:
when event x happens, i construct and start a timer with the callback function Func. Func checks if there are items in a list:
If there are items it handles the items
else it disposes the timer.
Func will occur in a timely fashion till list will be empty - and timer disposed.
If event x will happen again and the timer already exist - do nothing, if timer doesn't exist - construct it again.
|
|
|
|
|
Hi,
if it's a Windows.Forms.Timer its handler runs always on the GUI thread, so it can't reenter.
if it's a Threading.Timer or Timers.Timer it may reenter before it finished an earlier call.
Anyway, if you may need the timer again later on, why dispose and recreate it? a timer
is not that expensive, you could just Stop() it, and later Start() it again.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi Luc, thanks for answering me. i use Threading.Timer and i didn't see any Stop \Start methods.
I found only ways to set it to infinte time, thus disabling it. But then when i need to check
whether it's already disabled, the check seems akward - i have to check if it's set on infinte time.
Is there an equivalent of stop and start that i missed?
thanks and have a great day
|
|
|
|
|
Hi,
Threading.Timer has Change() method; the other two timer classes do have a Start() and
Stop() method, and an Enabled property, so they might be more appropriate for your purpose.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi,
I have currently a problem with my ListBox.
It's the first time I implement a specific draw item function
The problem is that when I clear my ListBox the draw function is still called !!!
I dont understand why, if I clear the list I shouldnt have any items in the list why is the draw function called ?
Thanks for any help !!
|
|
|
|
|
When the DrawItem event is fired and there are no items in the ListBox, then you really just need to draw the background. The DrawItemEventArgs[^] has an Index property which tells you which item you are drawing. If this value is -1, then you are not drawing an item (probably because there are none). In addition, the State property tells you what you need to draw.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Hi.
Im trying to make an automated gallery browser that can scroll through web pages and download all the images off them. It is currently working, using a webBrowser control. I have a list of all the images on the page in a listbox on the side, each with a thumbnail preview image. However, i am on dial up (laugh and get it out of the way), and the way the application currently works is to download the url to the browser, extract the img tags from the source code, and download each image as a bitmap. This takes ages as it has to download each image twice, once in the web browser and once from the url of the image.
I am wondering if there is anyway to extract the images from the webBrowser control so i dont have to download them twice?
I have played around with the webBrowser.DocumentStream, but cant work out how to get the images.
Any help appreciated.
-- modified at 18:23 Sunday 25th November, 2007
|
|
|
|