|
You really know how to make friends and get support. Here are the list of some things you did wrong:
Asked how to steal code in a software developer forum - don't give me crap about "learning"
Insulted someone who gave you an answer when it was not helpful (but was polite)
Tried lying to explain your motives which if true prove you are a fool.
Used text speak - this is not recommended. You have a keyboard try and use it.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
I have two methods in a windows application(am converting to a winservice). I need these methods to run after specific intervals with out user intervention. I have googled a bit and realize that i have 2 main options (correct me if i am wrong).
1. Threading
2. Timer (using TimerCallback)
I have ruled out threading because i want only one thread of execution. I want one of the method to execute at a time.
Timer would execute a method at intervals but my problem is that i want to run 2nd method every 1.5 hour where as the 1st method every 3 hrs. In cases where there is kind a collision method 1 should run first and then method 2. plz note first 90 mins , method 2 runs, 2nd 90 mins both should run but i want method 1 to run and then method 2 can run.
how do i solve such problem. Please provide a solution. Code snippet or idea or web url will highly be appreciated.
Thanx in advance
|
|
|
|
|
I don't believe you can or want to depend on any timer based mechanism to guarantee the order of two notifications. You need to account for that yourself.
Your posted requirements are not specific enough to determine this but perhaps you can have a single timer that fires every 1.5 hours since 1.5 + 1.5 = 3 hours. Therefore every other time it fires you just run both methods in the proper sequence. This could easily be accomplished using a finite state machine design.
|
|
|
|
|
Hi Mike,
Thanx for replying to both of my threads. this project was previously develpd and it had one module in a winservice, which ran after specific interval. to change the interval period and other settings a web application (asp.net) acted like a control panel. When i joined i was assigned to debug the service and add more functionality to it. To add more functionality i added another method. Now requirements are that both methods should run at different time periods but under scenerios where thread 2 and 1 come into conflict , thread 1 should run.
The timing of 90 mins and 180 mins that i mentioned was kinda an example. The timings can be any thing.
Still would i need to use one timer as u said?
Again thanx for ur response and yeah if i use a timer tick event, won't that be loading the whole page every time event is raised. isn't that performance overhead on server?
Thanx again
|
|
|
|
|
One barrier that I am hitting with your problem is the lack of a specification for this:
mark_me wrote: where thread 2 and 1 come into conflict
Without a specific definition for that I don't know that I can provide any meaningful help.
mark_me wrote: would i need to use one timer
Again that depends on the specific requirements. My comment was based on your orignal post of 1.5 + 1.5 = 3 hours. However you have now stated that those numbers are NOT part of the requirements.
|
|
|
|
|
led mike wrote: using a finite state machine design
yeah, that's what I would call a boolean flag if I were one of those high-brow consultants too.
Oh wait, I am.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
|
Luc Pattyn wrote: that's what I would call a boolean flag
You are likely joking, however on the serious side the OP already talks about changing requirements so when the 3rd feature is requested that boolean flag will be real helpful. I don't like to date myself but I've been around long enough to have OOD/OOP proven effective to my satisfaction beyond any doubt.
And keep in mind, that's with me doing it, so not high quality but it pays off big time none the less.
|
|
|
|
|
I would put the call to the two processes out into a single thread and then sleep the that thread.
A 90 minute sleep is not a great idea and I would allow for the process to be cancelled.
psudo code for the thread running:
proc1run = now + 180 minutes
proc2run = now + 90 minutes
running = true
while running
sleep 1 minute
if running
if proc1run < now
call proc1
proc1run = now + 180 minutes
if proc2run < now
call proc2
proc2run = now + 180 minutes
loop
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Hi,
one 90-minute timer suffices, on top of that you need a flag to indicate whether you need to run the other job. Pseudo-code:
bool infrequentJobFlag=false;
void TimerTick {
if (infrequentJobFlag) infrequentJob();
infrequentJobFlag=!infrequentJobFlag;
frequentJob();
}
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Hi all,
I've been trying to solve this problem for a while, and no amount of researching or googling appears to be helping! This may not sound completely logical, but I have my reasons for it (I'm converting a very old Delphi program)...
Basically, I wish to display a ComboBox in the ComboBoxStyle.Simple mode, without showing the list portion.
At the moment, I have a property called 'zEnabled'. When this is true, the ComboBox should work 'normally' (i.e. an arrow and a droplist). When it is set to false, the user should still be able to scroll through the options, but not drop the list.
So ideally, for zEnabled = true, I have ComboBoxStyle.DropList, and for zEnabled = false, I have ComboBoxStyle.Simple, but with the list not being visible.
Any help/suggestions greatly appreciated.
|
|
|
|
|
Alternatively of course, if I can just hide the drop down button, I can stifle the drop down behaviour.
So, I'm either looking to hide the list portion in ComboBoxStyle.Simple mode, or hiding the dropdown button...
|
|
|
|
|
How about:
if (! zEnabled)
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
else comboBox1.DropDownStyle = ComboBoxStyle.Simple;
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Hi, thanks for the reply.
That's pretty much what it's doing at the moment. The problem is that in 'Simple' mode, the list is displayed as a box below the selection box permanently. It's this bit that I wish to remove, so that the combobox appears like a normal text box.
|
|
|
|
|
Hmmmm. In my test it doesn't show the list at all. It just appears like a TextBox but lets you scroll through the list items with the arrow keys. Did you perhaps set a size parameter or number of items to show?
I simply grabbed a ComboBox and put it on a Form, added a few items, and made a button that changed modes as above to test the behavior.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Interesting... it does appear to behave itself throughout the program with a pre-designed ComboBox.
However, if I dynamically create a custom ComboBox in code, and change the ComboBoxStyle, the list will not disappear. I've tried adjusting the size of the box but this has no effect, they always appear with an ugly big box underneath.
Why would it do this only for dynamically created ComboBoxes?
Thanks for looking at this with me, it's much appreciated.
|
|
|
|
|
My guess, based on experience, is that there's probably some default parameter in the pre-designed and dynamically created controls that is different, but I have no idea which one.
I've run into that problem with other controls before and tracking down the parameter was tedious. Perhaps you could put a pre-designed control on a form, then add a second one dynamically, then stick in a break point and examine all the parameters one by one to see where the difference is.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
I'm getting the impression that when the component is initially drawn in simple mode it is drawing to a default size - I'm getting around it at the moment with a 'bodge' where I'm explicitly resizing the boxes after they have been drawn - not idea, but it acheives the result.
If I get some I'm going to examine the parameters as you suggested.
Thanks for all the suggestions and help.
|
|
|
|
|
This is a bit of an odd question, but can I select a new row in a dgv and clear the old selection as an atomic operation? I can do it in two statements but that results in the SelectionChangedEvent firing twice.
dgv.ClearSelection();
dgv.Rows[e.RowIndex].Selected = true;
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
I don't believe that you can.
It is possible to override SetSelectedRowCore where you could put the ClearSelection , but that would, to all intents, be the same as having MultiSelect = false
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Can anybody have code , of retrieving the signatures in c# in OUTLOOK 2007.
i am developing an addin in outlook 2007,which sends email
but what i want is that default signature of the sender should be send automatically with each email message.
Regards
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
|
ok , don't give me any code any suggestion.
Please don't give this useless reply.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Mogaambo wrote: Please don't give this useless reply
Hardly useless. There you will find poeple who will be only too happy to work for you.
Of course, they will want paying...or had you noticed that?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
It's the most useful reply you will get, trust me.
Either go to rentacoder, or give your client back his money and let someone willing to do research or someone with prior knowledge benefit from their talent. Not a hack like you trying to get free code to profit off of it.
|
|
|
|