|
i couldn't do what u told me
plz can anyone help
|
|
|
|
|
Which method did you try?
|
|
|
|
|
Dear all,
i am doing some analysis on RC4 TKIP.I want to create an RC4 key and XOR it with data.My RC4 key is Ok.But i want to pass it as a parameter so as to do encryption.
Can anyone among you help
Thanks
NB
|
|
|
|
|
NalBH wrote: encryption in C of RC4
Then perhaps you should ask in a forum about C, not C#.
NalBH wrote: i am doing some analysis on RC4 TKIP.I want to create an RC4 key and XOR it with data.My RC4 key is Ok.But i want to pass it as a parameter so as to do encryption.
Can anyone among you help
Maybe if you explain why this is a problem. You have only explained what you want to do, but not why you need any help with it.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi guys,
I am having a weird problem and desperately need your help. I am trying to end the while loop with a timer. Here is how I am doing it.
public int status=0
in my function I have the following:
MessageBox.Show(this,"Please click on Ok to continue");
timer1.Enabled=true;
timer1.Start();
while(status!=1)
{
Thread.Sleep(500);
if(status==1)
{
break;
timer1.Enabled=false;
}
}
in my timer tick function I am asking the question whether they want to keep waiting and if they press no then I am changing status=1 and breaking the loop. My timer code doesn't get executed for some reason. I believe while loop blocks the message from the timer_tick, is there a way to allocate resources while in the while loop. Somehow force the message while in the while loop. I hope I am making sense. Please help!!!
sasa
|
|
|
|
|
I dont see any timer event wiring
|
|
|
|
|
I have a timer_tick event, i didn't add that code
sasa
|
|
|
|
|
I would not use the while(status!=1). Look into thread synchronization objects such as ManualResetEvent or AutoResetEvent and replace it with WaitOne
only two letters away from being an asset
|
|
|
|
|
You are blocking the main thread with your loop, so there is no thread that is handling the messages. The timer component is driven by messages from windows, and when there is no thread that handles the messages, the component doesn't get any tick events.
You should handle this without a loop, just disabling the parts of your application that should not be available while the timer is running. You can put a DoEvents() call in the loop for a quick fix, but you have to add code to prevent reentering the function regardless of how you handle it.
If you need a loop to do some heavy work, you should do that in a backgrond/worker thread instead of in the main thread.
---
single minded; short sighted; long gone;
|
|
|
|
|
Thank you Guffa for your comments, i understand what you mean. Basically what I am trying to do is wait for a response and while waiting I want the timer to ask if I still want to wait, can you please guide me on how to go about this without a while loop.
Please!
sasa
|
|
|
|
|
What do you want the program to do while waiting? Or perhaps more important, as a program almost always is waiting for someting, what do you want the program not to do while waiting?
---
single minded; short sighted; long gone;
|
|
|
|
|
Here is what I am doing, I am working on Symbol signature pad, in the timer I am waiting for the user to sign and click on the enter button on the signature capture. Basically, in my while condition I am checking if the user pressed the enter on the signature pad. But I need a timer in case the user never signs and walks off or something, you know what I mean.
I used the doevents() and it works but as you mentioned this is not a good solution. I am not sure how to go about this issue. Please advice
Thank you very much for all your suggestions.
sasa
|
|
|
|
|
Hi Guffa,
I am sure that was a rhetorical question.
I expect every one wants a program to remain responsive, so one can move the forms,
minimize/maximize; and even cancel lengthy operations.
In technical terms that means the GUI thread should never spend
more than say 100 milliseconds on some calculation, and should not include
long loops (with or without Sleep calls in them).
Actually, the GUI thread in many regards resembles an Interrupt Service Routine:
it should be swift and delegate everything that may take a while or could be blocking
to another thread; and hence it should not include delays at all.
Greetings
|
|
|
|
|
Luc Pattyn wrote: I am sure that was a rhetorical question.
No, it wasn't.
I believe that you misunderstood it, and that the way you understood it, it might make sense to be rhetorical.
Luc Pattyn wrote: I expect every one wants a program to remain responsive, so one can move the forms,
minimize/maximize; and even cancel lengthy operations.
Yes, that's what I mean when I am talking about that an applications usually is waiting for something. It's waiting for the user (or the system) to do something that it can react to.
When I am talking about what an application should not do, I mean the things that should be disabled while something else is happening. If the application is waiting for some process to finish, it should probably not be possible to start the process again until the first has finished.
---
single minded; short sighted; long gone;
|
|
|
|
|
SASA_1 wrote: break;
timer1.Enabled=false;
Disregard the other answers! Your 'break' needs to be after the disabling of the timer
|
|
|
|
|
leppie wrote: Disregard the other answers!
Perhaps you should try to understand the other answers before making such a statement.
leppie wrote: Your 'break' needs to be after the disabling of the timer
Although that is true, it is not the cause of the problem.
Moving the break will not make the timer work. As the tick event is never triggered, the code that sets the flag is never executed, so the code you are talking about is never even reached. Changing code that is never reached will not change how the program works.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hello,
You could use the System.Threading or System.Timers Timer instead of the Forms.Timer.
This Timers are executed in an new Thread and will not be blocked by the GUI Thread.
But make shure that you clearify your concept as Guffa suggested before you are using the timer.
All the best,
Martin
|
|
|
|
|
Thank you very much for your suggestion. I just used doevents() for now and it is working. I will research more into your suggestion. Thanks again.
sasa
|
|
|
|
|
Hello,
Maybe I was not clear before.
I will never suggest to stay at your concept, and build a workaround with a Threading Timer. I also do not like the DoEvents solution, which will have a lot of different side effects in your application.
All the best,
Martin
|
|
|
|
|
Hi Martin,
I do not agree. It is technically correct another kind of timer would
be able to intervene, but a while-forever loop in the main thread is
unacceptable; it prevents normal GUI interaction such as moving the form.
Once things get handled in a decent way, any timer can do what is needed,
so the Forms.Timer can stay.
Regards,
|
|
|
|
|
Hello Luc,
Luc Pattyn wrote: I do not agree
I don't think that you have to disagree.
Luc Pattyn wrote: but a while-forever loop in the main thread is
unacceptable
I completely agree with you!
That's why I suggested or better pointed out, that he should better change his concept, like Guffe suggested.
Maybe it was not understandable enough.
Presenting the posibility of the other Timers was just meant as an additional info!
All the best,
Martin
-- modified at 15:45 Friday 29th June, 2007
|
|
|
|
|
Hi Martin,
I am sure we agree. But we may use different styles:
I try not to present information that increases the chance the heart of the problem
is not dealth with.
As we all know, apps must be built with a good architecture, and not based on some
shaky code that has been tweaked until it seems to work.
Now if we dont try to get basic things corrected early on, a poster will come
again and again, every time he wants to add or correct a small thing, and it
becomes more and more difficult to set things right.
Greetings,
|
|
|
|
|
I am trying to open a C# app and sense if there are any open workbooks and then return thier names.
I can open a new one and sense it, but I want to sense any that are already open.
Thanks in advance for any assistance.
Jeff Beagle
jeffbeagle@hughes.net
|
|
|
|
|
Does anyone know how to implement ActiveX Persistence in C#? From an article on Code Project I discovered how to create an ActiveX object in C# but it does not implement any persistent interface.
Thank you.
Michael
|
|
|
|
|
How to count to optional item occurence in array? I looked at it all array class methods, but I did not find one like this.
I say thank you for the help!
|
|
|
|