1 / 16

Multi-Threading WPF Inside of AutoCAD

Multi-Threading WPF Inside of AutoCAD. Fenton Webb Autodesk Developer Evangelist . About the Presenter. Fenton Webb Developer Technical Services Americas Autodesk, Inc http://twitter.com/fentonwebb

doli
Download Presentation

Multi-Threading WPF Inside of AutoCAD

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Multi-Threading WPF Inside of AutoCAD Fenton Webb Autodesk Developer Evangelist

  2. About the Presenter Fenton WebbDeveloper Technical ServicesAmericasAutodesk, Inc http://twitter.com/fentonwebb Fenton has been a member of the Autodesk DevTech team since 2000. Originally a member of our EMEA team, he has recently relocated to California to work for DevTech Americas.  Fenton is an expert in all the AutoCAD APIs, AutoCAD OEM, RealDWG and Plant3d. He particularly enjoys travelling to evangelise the APIs he support at our annual Developer Days conferences.  Before joining Autodesk, Fenton worked for an ADN partner developing ObjectARX applications in the Civil and Structural Engineering domain.

  3. Autodesk Developer Network • Access to almost all Autodesk software and SDK’s • Including early access to Beta software • Members-only website with 1000s of technical articles • Unlimited technical support • Product direction through conferences • Marketing benefits • Exposure on autodesk.com • Promotional opportunities • 1 to 3 free API training classes • Based on user level www.autodesk.com/joinadn

  4. Agenda What is WPF? What is Multi-Threading? Multi-Threading and WPF What about Multi-Threading WPF inside of AutoCAD?

  5. What is WPF? Technical Information Windows Presentation Foundation • Next Generation GUI Developer Platform from Microsoft • New update to WinForms • Packaged with .NET Version 3.0 • Driven by Direct3D drivers • Uses XAML • eXtensible Application Markup Language • XML based • Declarative Language • Requires very little programming

  6. What is WPF? Let’s see it for real... Windows Presentation Foundation by Microsoft

  7. What is Multi-Threading? All about Threads... The utilization of multiple concurrent execution threads in the same process • Threads… • Are used to do “work”. • Run separately from UI/Main Thread. • Share the same application resources as the UI/Main Thread. • Usually need to notify the Main Thread of “work” that is complete • To update UI, etc. • Only use what you need. Reuse. MyApplication.exe Thread 2 Thread 1 Spawn Spawn Main Execution Thread Notify Notify Spawn Thread 3 Notify Resources

  8. Multi-Threading and WPF Rules of… • WPF works on the UI/Main Thread • Based on Windows Messaging, like MFC/Win32 • Worker thread UI updates must be done on the UI/Main Thread • You cannot update WPF UI from a worker thread • You need to switch to the UI/Main thread.

  9. Multi-Threading and WPF Tools of the Job WPF derives all controls from DispatcherObject • Allows easy invocation of code on the Main Thread. • MyControl.Dispatcher.BeingInvoke() – asynchronous • Allows you to set an update priority • MyControl.Dispatcher.Invoke() – synchronous • For UI lots of updates per second • Recommend using the DispatcherPriority.Background priority setting • Too many updates can cause the UI to become slow and/or jerky • Use a timer to know when you authorize an update

  10. Multi-Threading and WPF Tools of the job - Timers Timer classes.NET provides • System.Windows.Forms.TimerRuns on UI main thread only. • System.Timers.Timer Runs on UI main thread, or worker thread • SynchronizingObject is not compatible with WPF • System.Threading.Timer Worker thread only. • All can be used fairly easily inside of WPF

  11. Multi-Threading and WPF Tools of the job - Threading Threading classes.NET provides • System.Threading.Thread class • Raw .NET threading class • I don’t recommend using this class in WPF • BackGroundWorkerclass • Neatly packages up multi threading to work with WPF • Perfect for use with WPF • Thread switching automatically taken care of • Switching from the worker thread to the main thread.

  12. Multi-Threading and WPF Simple Example Demo “Simple Windows Application” Demonstrating Windows Application Using threads Providing Feedback while doing “work”

  13. What about Multi-Threading inside AutoCAD Is it possible? • AutoCAD is an Single Threaded Application • You cannot use worker threads to access any part of AutoCAD. • It will crash. • You may do none-AutoCAD related “work”

  14. Multi-Threading and WPF AutoCAD Ribbon Example Demo “AutoCAD Performance Monitor” Demonstrating CUI Custom Control Using Timers Using WPF Dispatcher Using BackGroundWorker Providing Feedback while doing “work”

  15. Multi-Threading WPF Inside of AutoCAD Fenton Webb Senior Developer Evangelist Thank you…

More Related