WPF XAML demo: Difference between revisions

Jump to navigation Jump to search
11 bytes removed ,  13:19, 7 May 2020
This is an essay, not an article, so it shouldn't use article subject styling
(This is an essay, not an article, so it shouldn't use article subject styling)
(One intermediate revision by one other user not shown)
Line 1: Line 1:
'''wpfXamlDemo''' is a [[Dyalog APL]] demonstratration of WPF XAMPL with some utility functions, delivered in the form of a [[namespace]].
This page gives a [[Dyalog APL]] demonstratration of WPF XAMPL with some utility functions, delivered in the form of a [[namespace]].


Please read the Dyalog tutorials for a more detailed explanation. Part of the code was taken from ''[http://www.codeproject.com/Articles/22980/WPF-A-Beginner-s-Guide-Part-of-n CodeProject: A Beginner's Guide]''.
Please read the Dyalog tutorials for a more detailed explanation. Part of the code was taken from ''[http://www.codeproject.com/Articles/22980/WPF-A-Beginner-s-Guide-Part-of-n CodeProject: A Beginner's Guide]''.
Line 613: Line 613:
The author has taken the prefix '⍝∇' instead of '⍝' because in production code you will probably want to erase all the comments in your runtime WS because they are useless and it is helping to obfuscate the code while taking less space.
The author has taken the prefix '⍝∇' instead of '⍝' because in production code you will probably want to erase all the comments in your runtime WS because they are useless and it is helping to obfuscate the code while taking less space.
==== With a DispatcherTimer ====
==== With a DispatcherTimer ====
If you have a repetitive task to be executed on the UI thread then you can use a [[https://msdn.microsoft.com/en-us/library/system.windows.threading.dispatchertimer(v=vs.110).aspx|DispatcherTimer]] like this:
If you have a repetitive task to be executed on the UI thread then you can use a [https://msdn.microsoft.com/en-us/library/system.windows.threading.dispatchertimer(v=vs.110).aspx DispatcherTimer] like this:
<source lang=apl>
<source lang=apl>
     ⎕USING∪←'System.Windows,WPF/WindowsBase.dll' 'System,mscorlib.dll'
     ⎕USING∪←'System.Windows,WPF/WindowsBase.dll' 'System,mscorlib.dll'
Line 623: Line 623:
Note that since the <source lang=apl inline>DispatcherTimer</source> is executed on the UI thread you cannot have a long callback because it will freeze the UI during its execution.
Note that since the <source lang=apl inline>DispatcherTimer</source> is executed on the UI thread you cannot have a long callback because it will freeze the UI during its execution.
==== With a BackgroundWorker ====
==== With a BackgroundWorker ====
The .NET framework provides a simple way to get started in threading with the [[https://msdn.microsoft.com/fr-fr/library/cc221403(v=vs.95).aspx|BackgroundWorker]] component. This wraps much of the complexity and makes spawning a background thread relatively safe. It offers several features which include spawning a background thread, the ability to cancel the background process before it has completed, and the chance to report the progress back to your UI. The <source lang=apl inline>BackgroundWorker</source> is an excellent tool when you want multithreading in your application with access to the UI thread, mainly because it's so easy to use.
The .NET framework provides a simple way to get started in threading with the [https://msdn.microsoft.com/fr-fr/library/cc221403(v=vs.95).aspx BackgroundWorker] component. This wraps much of the complexity and makes spawning a background thread relatively safe. It offers several features which include spawning a background thread, the ability to cancel the background process before it has completed, and the chance to report the progress back to your UI. The <source lang=apl inline>BackgroundWorker</source> is an excellent tool when you want multithreading in your application with access to the UI thread, mainly because it's so easy to use.


An example is included in this namespace. It is inspired by this [[http://www.wpf-tutorial.com/misc/multi-threading-with-the-backgroundworker/|article]].  You start the example by doing:
An example is included in this namespace. It is inspired by [http://www.wpf-tutorial.com/misc/multi-threading-with-the-backgroundworker/ this article].  You start the example by doing:
<source lang=apl>
<source lang=apl>
       BackgroundWorkerSample& 1000
       BackgroundWorkerSample& 1000

Navigation menu