|
Hi,
I would set DoubleBuffered only once, probably in the constructor.
Maybe setting it every time causes the flickering you see.
And you either should make your pens class members (so they get created only once),
or Dispose of them every time you create them (wasting CPU cycles in creation, disposal
and garbage collection).
I am not sure what "AccelReadings=true" is supposed to do there. Seems not to belong
in a paint handler.
Final remark: the comment "Line that is drawn when timer event occurs" is inaccurate,
the line is drawn every time paint is executed (which could be on every time tick and
more), it probably gets instructed to move in the time tick handler.
Hope this helps.
|
|
|
|
|
Laura,
Another thing you can try is your own simple double buffering: Paint everything to a temporary bitmap and then paint the bitmap to the graphics passed by the event args, like so:
Bitmap temp = new Bitmap(e.ClipRectangle);
// do your painting
e.Graphics.DrawImageUnscaled(temp, e.ClipRectangle);
That may help.
Incidentally, are you using transparency of any kind? Transparency can cause flickering despite double buffering.
|
|
|
|
|
we are creating Online Exams Module.Just lke any other online exams on other real sites.
The Case is the user can attempt any question within 3 minutes.after 3 minutes,the next question automatically disappears and another question comes on the page.
We also want to show times in Minutes as a clock just like any other online exams.
My issue is that how can i show time on each page and how can i calculate every 3 minutes.
I know there is Timer/Thread class in c# for web application.But i dont know how they can efiicently work.
Or there is any other better method to do it.
Plaese help me with example or code.
---
My code is like this:-
System.Timers.Timer time1=new Timer();
time1.AutoReset=true;
time1.Interval=60000;
time1.Elapsed+=new ElapsedEventHandler(time1_Elapsed);
And..
private void time1_Elapsed(object source,System.Timers.ElapsedEventArgs e)
{
//call any function
}
but my WebForm seems running ambigously to me and not giving proper result.
Am i in right direction.
Please help me with suitable simple.
MY PLATFORM IS ASP.NET 2005
Posted via DotNetSlackers.com
|
|
|
|
|
Hold the timer object in session variable
It' will be work.
Parwej Back...............DON of Developer.......
Parwej Ahamad
g_parwez@rediffmail.com
|
|
|
|
|
|
Jeez - You get impatient after only half an hour. Perhaps, if you need the information this fast, you might want to pay for a support call to Microsoft. Here you will get help by volunteers who help out when they can, not at your whim.
|
|
|
|
|
You've been here for over two years, so you should know how a forum environment works by now. Making a demand like this after waiting only 30 minutes is just ludicrous.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I am working on one app
Ihave one gridview where i write information but when i restart my app the informations are gone!!??
Help me !!!!
Please!!!!
Thanks
nemanja
|
|
|
|
|
You will need to persist the data somehow.
That is, when a new row is added you need to find some method to take the data contained within that row, and store it somewhere. That could be a database, xml file, plain text file or something else - it's up to you, you're the developer. It's not excel.
|
|
|
|
|
I have a class assembly that references the IMB WebSphere MQ system. I have to register the MQ one time before I can start making calls. I would like to do this when I load my class assembly. What's the best way to achieve this?
Tanks
Phil
|
|
|
|
|
You can do this in the class constructor (or a static constructor) as long as you put the appropriate safegaurds in place.
You want to make sure that once MQ has been registered you don't try to do it again. You also want to make sure that if the registration fails, your constructor doesn't throw an exception but sets the class state in such a way that the class is created but not usable. Throwing an exception in the constructor will result in a very ambiguous "Type initialization failed" error message.
The better way would be to create a singleton class that manages the relationship with MQ. The singleton is instantiated once in your class constructor. It would need to provide an explicit "register" method, and any other methods that access MQ would be part of this singleton and can take advantage of the register method implicitly. The benefit here is that everytime you make a call to MQ, the system verifies that MQ has been registered, and if not registers it before making the call.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
I had thought about that approach. I'm trying to eliminate the need for the user of my library to initialize the library (hiding the details). It's almost like the global.asax file - with the Application.Start event. If there was an Assembly.Load event or something similar that i could hook into, so the initialization could be done automatically.
Phil
|
|
|
|
|
There aren't any equivalent events like Assembly.Load. It still sounds like the best approach would be to implement a singleton MQManager class. Since it is a singleton you can hide all of the initialization details behind an explicit Register method. Each "normal" method can check the state and initialize as needed.
Something like this (rough pseudo-code):
public class MQManager {
private bool registered;
public void Register() {
if (!registered) {
registered = true;
}
}
public void AddMessage() {
Register();
MQ.Add();
}
}
Since the Register function protects itself from registering more than once through the registered flag, it is safe to call multiple times. Also, since the AddMessage function makes a call to Register before doing anything else, it is safe to be called by the user without having first explicitly called Register .
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
I appreciate the help.
If that's what I got do - then that's the way I'll go.
Tanks
Phil
|
|
|
|
|
well, i have a timer initilized and started in the Form constructor :
tmpTimer = new System.Timers.Timer(1000);
tmpTimer.Elapsed += new ElapsedEventHandler(tmpTimer_Elapsed);
tmpTimer.Start();
the timer start in the form constructor and keep checking a bool variable(doThing),
if this variable is set to true in the program, the timer excute the event handler,
private void tmpTimer_Elapsed(object sender, ElapsedEventArgs e)
{
if (doThing == true )
{
MessageBox.Show(doThing.ToString());
}
}
but i want the event handler to excute only once(at the time that doThing is set to ture
, so i add one line of code to change the value of doThing to false,to prevent excuting
of the event handler.
private void tmpTimer_Elapsed(object sender, ElapsedEventArgs e)
{
if (doThing == true )
{
MessageBox.Show(doThing.ToString());
doThing = false;
}
}
but the poblem it's that the value of doTing dose not changed, and messageboxes keep
showing in screen every one second (with True printed on them) till i close one of
them, then they stoped showing.
what i want is to prevent timer from entring if block by changing doThing to false.
i don't know what is realy happened there, any gusse or suggestion would be helpfull,
thanks in advance.
|
|
|
|
|
MSDN states: "The Elapsed event is raised on a ThreadPool thread. If the processing of the Elapsed event lasts longer than Interval, the event might be raised again on another ThreadPool thread."
Since the MessageBox.Show method is a blocking method, doThing is true until you close the first message box, and the execution of the event handler on additional Threadpool threads causes the appearance of a new message box every seconds.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
If you move doThing = false above the MessageBox.Show , there will be a small improvement, but there would still be a possibility of multiple message boxes.
You could try using System.Threading.Timer[^] instead and it provides a parameter to do one shot firing of the timer. Something like
void StartTimer()
{
int dueTime = 5000;
object state;
System.Threading.Timer timer = new System.Threading.Timer(new TimerCallback(TimerMethod), state, dueTime, Timeout.Infinite);
}
Passing Timeout.Infinite as the last parameter makes the timer run only once.
|
|
|
|
|
S. Senthil Kumar wrote: You could try using System.Threading.Timer[^] instead and it provides a parameter to do one shot firing of the timer.
The same can be achieved by setting the System.Timers.Timer.Autoreset property to false .
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
The documentation[^] on the property doesn't say that the timer will fire only once, it says that the Elapsed event will be raised only once, the first time the timer elapses. You could argue it's the same, but the OP has to write code to stop the timer.
|
|
|
|
|
|
In VB there is this out of focus even for a text box. Can some one tell me the equivalent for C#?
I would like to validate a value in the text box when we leave this text box.
Suggestions?
Thanks,Arun
|
|
|
|
|
mrarunks wrote: In VB there is this out of focus even for a text box. Can some one tell me the equivalent for C#?
It is the same framework, so it will have the same events (Unless, by VB you are talking about VB6 or ealier)
|
|
|
|
|
Enable the CausesValidation property and register to the Validating event.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
i need to write method and return somevalue from that method
for example return number
and use that number in the rest of application
ma_refay
|
|
|
|
|
From your question I can tell you need more help than can be provided here.
only two letters away from being an asset
|
|
|
|