• ClipSaver
  • dtub.ru
ClipSaver
Русские видео
  • Смешные видео
  • Приколы
  • Обзоры
  • Новости
  • Тесты
  • Спорт
  • Любовь
  • Музыка
  • Разное
Сейчас в тренде
  • Фейгин лайф
  • Три кота
  • Самвел адамян
  • А4 ютуб
  • скачать бит
  • гитара с нуля
Иностранные видео
  • Funny Babies
  • Funny Sports
  • Funny Animals
  • Funny Pranks
  • Funny Magic
  • Funny Vines
  • Funny Virals
  • Funny K-Pop

C# 01: Update UI control from background thread in WPF with Dispatcher скачать в хорошем качестве

C# 01: Update UI control from background thread in WPF with Dispatcher 6 лет назад

скачать видео

скачать mp3

скачать mp4

поделиться

телефон с камерой

телефон с видео

бесплатно

загрузить,

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
C# 01: Update UI control from background thread in WPF with Dispatcher
  • Поделиться ВК
  • Поделиться в ОК
  •  
  •  


Скачать видео с ютуб по ссылке или смотреть без блокировок на сайте: C# 01: Update UI control from background thread in WPF with Dispatcher в качестве 4k

У нас вы можете посмотреть бесплатно C# 01: Update UI control from background thread in WPF with Dispatcher или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:

  • Информация по загрузке:

Скачать mp3 с ютуба отдельным файлом. Бесплатный рингтон C# 01: Update UI control from background thread in WPF with Dispatcher в формате MP3:


Если кнопки скачивания не загрузились НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу страницы.
Спасибо за использование сервиса ClipSaver.ru



C# 01: Update UI control from background thread in WPF with Dispatcher

Here is a summary of the background knowledge that is directly related to the topic of this tutorial: (1) WPF is STA (Single-Threaded Apartment) application (2) UI controls can only be created on STA thread (3) A control can only be accessed on the same thread it is originally created Since they are self-explanatory, I won't spend time explaining them. Instead, we will go through a WPF program to illustrate how they affect the behavior, or require dispatcher class. (Demo starts) I am using Visual Studio 2017. Create a new WPF application. Select template: WPF App using .NET Framework. The default .NET version is 4.5. Check "Create directory for solution". Save to the location of your preference. Before we make any change, run the program with Ctrl + F5. Make sure no problem. Right-click on the source code tab. Select "open containing folder". Look at the attribute for Main() in the folder \obj\Debug. Open automatically generated file App.g.cs. App is defined as partial class. The attribute for Main() method is declared as STA thread. This clarifies our first statement: WPF is STA (Single-Threaded Apartment) application. There is nothing for us to modify here. It just helps us to understand better the nature of WPF application. [System.STAThreadAttribute()] public static void Main() { } Come back to Visual Studio. Open Toolbox with shortcut Ctrl + Alt + X, add two buttons and one label to the main window design area. Now update their properties in Properties pane. Change the name of the label to "lblMessage", and text size to 72 px. Change the name of left button to "btnOnce", text size to 48 px, and content to "Once". Change the name of right button to "btnContinuous", text size to 48 px, and content to "Continuous". Adjust the control size if necessary. That's all for our GUI design. Run the program and you shouldn't see any error. Double click on buttons to add click event handlers. Now we have event handlers for both button Once and button Continuous. Add a class scope variable _count as integer and assign 0. It's optional to add private access modifier. It's default to private. Implement button Once event handler. Increment _count variable. Update message label with number of clicks. Run the program. Click button several times. The message is updated accordingly. So far we are updating UI label control from UI thread. It works flawless. Now assume we want to call a long running method to alternate label background color from red to yellow, back and forth every half a second. First, let's find out what could happen if this method is called in UI thread. Add a method to update label background, accepting integer state as parameter. Use switch block to decide which background color is applied to label: red when state is 1, yellow when state is 2. This is a simple routine. Add another method, without a better name, we call it Long_running. To display the possible exception message, that we expect will happen at some point in this tutorial, add try catch block. Use message box to show the exception details. Use endless loop to simulate a long running process. Set delay to 500 ms. Call update label background method with argument 1 and 2 with interval as defined. Now call Long_running method from button Continuous event handler. How bad it could be? Let's run the program and find out. Click button "Once". It works as before. Now click button "Continuous". Do you expect smoke and flames? Actually no, the application is simply frozen, not responding. Try to close the program. It complains the application is not responding. OK, that's understandable. We shouldn't block the UI thread with long running process, otherwise, bad things happen. Of course, there are some work around, like using timer, to alternate background color in the UI thread. But that's not what I want to focus on in this tutorial. We want to put this long running process in the background thread. (demo ends) Here is the complete code: (1) part 1 with button Once event handler (2) part 2 with button Continuous event handler, and update label background method (3) the essential code is in part 3 with Dispatcher BeginnInvoke implementation in Long_running method The complete program can be also be found at Github with this link: https://github.com/lileowang/Demo_cs/... Here is a brief recall of what we have learned: (1) WPF is STA application (2) UI controls can only be created and accessed on UI thread (3) To access UI controls from non-UI thread, Dispatcher must be used Thanks for watching!

Comments
  • Как использовать PowerShell и WPF для создания сложных графических интерфейсов пользователя 1 год назад
    Как использовать PowerShell и WPF для создания сложных графических интерфейсов пользователя
    Опубликовано: 1 год назад
  • C++ 01: unique_ptr prevents memory leaks 6 лет назад
    C++ 01: unique_ptr prevents memory leaks
    Опубликовано: 6 лет назад
  • WPF INotifyPropertyChanged and Databinding 4 года назад
    WPF INotifyPropertyChanged and Databinding
    Опубликовано: 4 года назад
  • Программирование на ассемблере без операционной системы 3 месяца назад
    Программирование на ассемблере без операционной системы
    Опубликовано: 3 месяца назад
  • .NET Core Console App with Dependency Injection, Logging, and Settings 5 лет назад
    .NET Core Console App with Dependency Injection, Logging, and Settings
    Опубликовано: 5 лет назад
  • Как взломать любое программное обеспечение 3 месяца назад
    Как взломать любое программное обеспечение
    Опубликовано: 3 месяца назад
  • Лижут ли Вас Собаки? ВОТ ЧТО ЭТО ЗНАЧИТ (вас шокирует)! 1 день назад
    Лижут ли Вас Собаки? ВОТ ЧТО ЭТО ЗНАЧИТ (вас шокирует)!
    Опубликовано: 1 день назад
  • C# Events and Delegates Made Simple | Mosh 11 лет назад
    C# Events and Delegates Made Simple | Mosh
    Опубликовано: 11 лет назад
  • The Windows 11 Disaster That's Killing Microsoft 3 дня назад
    The Windows 11 Disaster That's Killing Microsoft
    Опубликовано: 3 дня назад
  • How to Store and Retrieve Setting  In WPF 2 года назад
    How to Store and Retrieve Setting In WPF
    Опубликовано: 2 года назад
  • WPF MVVM Step by Step ( Windows Presentation Foundation) 11 лет назад
    WPF MVVM Step by Step ( Windows Presentation Foundation)
    Опубликовано: 11 лет назад
  • Задача про надёжный пароль | В интернете опять кто-то неправ #035 | Борис Трушин и Математик Андрей 4 дня назад
    Задача про надёжный пароль | В интернете опять кто-то неправ #035 | Борис Трушин и Математик Андрей
    Опубликовано: 4 дня назад
  • Why is async void bad and how do I await a Task in an object constructor in C#? 5 лет назад
    Why is async void bad and how do I await a Task in an object constructor in C#?
    Опубликовано: 5 лет назад
  • ⚡️ Путин предложил Западу сделку || НАТО поставили перед условием 18 часов назад
    ⚡️ Путин предложил Западу сделку || НАТО поставили перед условием
    Опубликовано: 18 часов назад
  • Почему Собаки Вдруг ЗАЛЕЗАЮТ На Вас? (Причина шокирует) 5 дней назад
    Почему Собаки Вдруг ЗАЛЕЗАЮТ На Вас? (Причина шокирует)
    Опубликовано: 5 дней назад
  • Покойся с миром, Arduino и Open Hardware... спасибо Qualcomm 1 месяц назад
    Покойся с миром, Arduino и Open Hardware... спасибо Qualcomm
    Опубликовано: 1 месяц назад
  • Где начало СХЕМЫ? Понимаем, читаем, изучаем схемы. Понятное объяснение! 9 месяцев назад
    Где начало СХЕМЫ? Понимаем, читаем, изучаем схемы. Понятное объяснение!
    Опубликовано: 9 месяцев назад
  • Переключение представлений в WPF с навигацией с использованием MVVM и внедрения зависимостей 3 года назад
    Переключение представлений в WPF с навигацией с использованием MVVM и внедрения зависимостей
    Опубликовано: 3 года назад
  • Синхронизация потоков в C# .Net стала проще! | Блокировка | Монитор | Мьютекс | Семафор | Codelli... 5 лет назад
    Синхронизация потоков в C# .Net стала проще! | Блокировка | Монитор | Мьютекс | Семафор | Codelli...
    Опубликовано: 5 лет назад
  • Windows Is Dying.. 3 дня назад
    Windows Is Dying..
    Опубликовано: 3 дня назад

Контактный email для правообладателей: u2beadvert@gmail.com © 2017 - 2026

Отказ от ответственности - Disclaimer Правообладателям - DMCA Условия использования сайта - TOS



Карта сайта 1 Карта сайта 2 Карта сайта 3 Карта сайта 4 Карта сайта 5