|
It has been a long time since I have made an installer but the msi should not reinstall itself it has already been installed. I would just leave it in the installer and it would work fine every time. But yes, if you install another app on the same computer with the same version of Crystal you will not need another msi, however, same is a word that will bite you on the rear, even in the .NET world.
|
|
|
|
|
Hi
I'm working with Mono.Cecil for IL Manipulation and find some articls like this[^]
but i didn't found any useful article about what's OpCodes and expain each OpCode item.
can anybody help me ?
thanks
|
|
|
|
|
Follow these easy instructions.- Go to http://www.google.com
- Type opcodes site:microsoft.com for your search criteria.
- Click the link entitled "OpCodes (System.Reflection.Emit)
That'll list the opcodes for you.
If you want to know how each works, read Standard ECMA-335[^].
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
|
This sounds like a job for the Specification Pattern[^]. This would let you inject your own logic into a more general method, reducing the need for code duplication.
There's a video presentation here[^], although be warned: JP Boodhoo goes about a million miles per hour and it took me several watchings just to understand that I already knew what he was talking about!
|
|
|
|
|
To whom it may concern,
I have a button onclick event, where I disable the button (setting its enable property to false), have some process which takes some time, and then reenabling the button at the end of the onclick event function. My query is that the onclick event is fired even though the button has been disabled (clicking more than once while the button is still disabled).
The following snippet illustrates the problem. Any solutions are appreciated.
private void button1_Click(object sender, EventArgs e)
{
DateTime d1, d2;
TimeSpan t;
d1 = DateTime.Now;
if (button1.Enabled == false)
return;
button1.Enabled = false;
while (true)
{
d2 = DateTime.Now;
t = d2.Subtract(d1);
if (t.TotalMilliseconds > 2000)
break;
}
label1.Text = (count++).ToString(); // shows the number of times the function has been called (count is a global variable)
label1.Refresh();
button1.Enabled = true;
}
Thanks in advance
|
|
|
|
|
Hmmm... very strange process. I assume you have done so just to play around with things.
your code is currently being executed on the UI thread when the button is clicked. This means that until the event process has been complete then the form will not be updated. You can use functions like Update or Refersh (like you have with label1) in order to make a change to the display/layout of the form/control. If you do not do so then it will only occur once the function is complete. So basically, even thou you are disabling the button in the function it will not be applied until the function is complete, but by then you have already enabled the button again.. So no change will be applied. You could try refreshing the button after you disable it and that should work (not tried before thou).
I would recommend that you take a look into Background Workers[^] as these can be used to process longer functions on a separate thread, thus freeing up the form for continued user interaction. There are alos a number of Timer Components[^] you may want to have a look at too.
djg wrote: if (button1.Enabled == false)
return;
Unless you are planning to 'emulate' the button click by calling the function specifically from code then you should not need to include that code. If you only ever use function when button is clicked by user than this should only ever evaluate to be false anyway
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Thanks for your quick reply. The main reason of disabling the button when the user clicks the button is that the code within the event will be executed only once. Once the code has been executed the button will be reenabled allowing the user to click the button. The problem is that even though the button has been disabled, and the program is still in the event function, the event will be fired once completed (given that the button has been clicked while it was disabled). It seems that the event queue is not cleared when the button has been disabled. The label shows the number of times the event has been called.
To ensure the event is only called once (while the button has been disabled) i have included this statement:
if (button1.Enabled == false) return;
I could use timers or threads, but I try to avoid them.
Thanks
|
|
|
|
|
djg wrote: I could use timers or threads, but I try to avoid them.
Timers is debatable, but not using threads (especially with the ease of Background Workers) is a big mistake. Like I have said, running code that will take more than a second (or even less) should not hold up the UI thread, this leads to bad user experience as in most cases the application will appear to crash/freeze and more than likely display the "Not Responding" message, which just makes the application look bad.
When a process is called on the UI thread then the form is not automatically updated until control has been return to it (so to speak). Unless you specifically 'interrupt' the function and tell it to do so.
Try my suggestion of using Refresh after you disable the button (which should be your first two lines within the event BTW) and see if that stops multiple clicks.
And if your counting the number of button clicks during the actual process then you should reset the counter to 1 at the start of each click, otherwise you are storing number of button clicks since form was created. - Sorry, a moment of stupidity
I strongly suggest attempting to use a background worker if you have not done so before.
Life goes very fast. Tomorrow, today is already yesterday.
modified on Tuesday, July 28, 2009 4:58 PM
|
|
|
|
|
Well, that's interesting. It's like the click is cached and processed once the control is re-enabled.
I used the following:
private void button1_Click ( object sender , System.EventArgs e )
{
System.Windows.Forms.Button button = sender as System.Windows.Forms.Button ;
System.Console.Beep() ;
if ( ( button != null ) && ( button.Enabled ) )
{
button.Enabled = false ;
System.Threading.Thread.Sleep ( 2000 ) ;
button.Enabled = true ;
}
return ;
}
|
|
|
|
|
hi
thanks for your quick reply. i have tried the code, but unfortunately it does not work. if you click the button twice within two seconds, you would hear two beeps meaning that the event has been fired, even though the second click was on a disabled button
this is a very strange issue, i guess the event queue is not cleared. if one does not enable the button at the end of the function, only one event will occur. for instance the following has the same consequences:
private void button1_Click(object sender, EventArgs e)
{
button1.Enabled = false;
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Enabled = false;
System.Console.Beep();
Thread.Sleep(2000); // could be a blocking function
button1.Enabled = true;
}
thanks
|
|
|
|
|
The problem here is you are disabling the button and then 'freezing' the UI thread.
So when you click the button, or anything in the form then that click can not be processed until the form unfreezes. The form will only unfreeze once the thread sleep has finished and the Tick event is complete (at which point the button is re-enabled) so the 'Click' is effectively done on an enabled button.
Basically it is the form that is processing your click and is can only do so when it the UI thread is free to do so.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Right, I hadn't meant that as a solution.
|
|
|
|
|
Here's a quick example of using a thread to do the task:
private void
button1_Click
(
object sender
,
System.EventArgs e
)
{
System.Windows.Forms.Control control =
sender as System.Windows.Forms.Control ;
if ( ( control != null ) && ( control.Enabled ) )
{
control.Enabled = false ;
(new System.Threading.Thread ( this.DoStuff )).Start ( control ) ;
}
return ;
}
private void
DoStuff
(
object Control
)
{
System.Windows.Forms.Control control =
Control as System.Windows.Forms.Control ;
if ( control != null )
{
System.Console.Beep() ;
System.Threading.Thread.Sleep ( 2000 ) ;
this.Enable ( control ) ;
}
return ;
}
private delegate void EnableDelegate ( System.Windows.Forms.Control Control ) ;
private void
Enable
(
System.Windows.Forms.Control Control
)
{
if ( Control != null )
{
if ( this.InvokeRequired )
{
this.Invoke
(
new EnableDelegate ( Enable )
,
new System.Windows.Forms.Control[] { Control }
) ;
}
else
{
Control.Enabled = true ;
System.Console.Beep ( 440 , 100 ) ;
}
}
return ;
}
|
|
|
|
|
Hi everyone out there !!!!
around 2-3 days back I wrote an article here, after which I received a mail that I got to explain it a bit more....... I did it......but it isn`t added yet.
can someone here pls tell me that how much time do they usually take to accept an article?
its my first time .... so am quite a novice here at codeproject
|
|
|
|
|
It won't be publicly visible until it's approved. I'll have a look at it now and post back through the article's forum, not through here. The correct place for questions such as this is probably Site Bugs / Suggestions[^] for future reference
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
It's still sitting there waiting for approval (by a gold+ member). Indeed it is better than when you first published it.
I promised myself I wouldn't approve any articles, but I guess I will, just this once.
|
|
|
|
|
Usually Articles are posted within a day
|
|
|
|
|
its has been added now....... thnx to all who wrkd!!!!
|
|
|
|
|
I have a windows forms application which does invoicing among other things.
When a new invoice line is created the user can request a modal form with article numbers. On this article select form I want to create a "new" button which loads another modal form on which the new article is defined.
C# says it can't launch a modal form from a modal form.
Does anyone have a solution ?
I'm flexible in architecture of the application so a different approach is fine.
Thanks in advance,
Rob
|
|
|
|
|
well I can use Form.ShowDialog() inside a Form which is displayed itself using Form.ShowDialog()... same thing you are looking for me thinks
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi,
Works for me with the following code where Form1 has one button.
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e) {
Form1 f = new Form1();
f.ShowDialog(this);
}
}
How are you creating and showing the forms?
Alan.
|
|
|
|
|
PosiRob wrote: C# says it can't launch a modal form from a modal form.
What are you telling?
How are you opening a modal form. Is it using
form.ShowDialog() [ where form is an object of your form ]
By this way you can open as many modal forms as you want.
|
|
|
|
|
Thanks for the quick replies. I created a simple application to test your comments, and it proves you are right.
I get the run time error when I want the modal form to be a child in an MDI application, and I misinterpreted the error message.
Problem solved, thanks again.
Rob
|
|
|
|
|
You are most welcome.
you can also rate the answers if it really helped you ..
|
|
|
|