Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / August 2006

Tip: Looking for answers? Try searching our database.

Drag & Drop & Timer

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lloyd Dupont - 10 Aug 2006 06:11 GMT
When doing a Drag & Drop SWF.Timer don't seem to work anymore.
What can I do in such case?

For now, as the OnDragOver event seems to be fire repetitively I use it.
But I cannot control the time interval.

Any better idea?
Mini-Tools Timm - 10 Aug 2006 13:55 GMT
> When doing a Drag & Drop SWF.Timer don't seem to work anymore.
> What can I do in such case?
>
> For now, as the OnDragOver event seems to be fire repetitively I use it.
> But I cannot control the time interval.

As you've discovered, the SWF.Timer is not what you need in this case.  As
stated on MSDN: "If you're looking for a metronome, you've come to the wrong
place. The timer events raised by this timer class are synchronous with
respect to the rest of the code in your Windows Forms app."

Instead you should consider using the System.Threading.Timer, as it will
produce the steady drumbeat you need, even during drag & drop.  However, the
timer callbacks occur in a separate thread, so you need to take proper care
when accessing any UI controls from your timer callback (use control.Invoke).

Here's an excellent article on the three timers available in .NET:

http://msdn.microsoft.com/msdnmag/issues/04/02/TimersinNET/

Signature

Timm Martin
Mini-Tools
.NET Components and Windows Software
http://www.mini-tools.com

Lloyd Dupont - 11 Aug 2006 02:11 GMT
I know about System.Threading.Timer but it is rather akward to use in GUI
code.... :-(
Well I don't really need a metronome, I just want to have a little animation
on the drop target...
I think I will stick to my implementation.

But thanks for your feedbacks! ;-)

Signature

Regards,
Lloyd Dupont

NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>

>
>> When doing a Drag & Drop SWF.Timer don't seem to work anymore.
[quoted text clipped - 20 lines]
>
> http://msdn.microsoft.com/msdnmag/issues/04/02/TimersinNET/
Stoitcho Goutsev (100) - 10 Aug 2006 16:54 GMT
The reason WF timer is based on windows messages that comes throught the
message queue. While D&D COM enters a modal loop and the application doesn't
process posted messages until the user is doen with the D&D operation, thus
the application stop registering timer's ticks. Nevertheless WF timers are
so incurate that you should always check with the system time.

If you need the timer working during D&D use some of the others timers that
the framework provides. Keep in mind thought that System.Timers.Timer can be
set to execute its Elapsed event in the main UI thread. If you use this
feature you'll run in the same situations as with the WF timer because the
thread switching is implemented using the message queue.

Signature

HTH
Stoitcho Goutsev (100)

> When doing a Drag & Drop SWF.Timer don't seem to work anymore.
> What can I do in such case?
[quoted text clipped - 3 lines]
>
> Any better idea?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.