Asynchronous Programming in c# using async await

async await keyword in c# with simple example. async await – basic example XAML <Window x:Class="AsyncAwait.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="async/await - mkumaran.net" Height="255" Width="331"> <StackPanel> <ListBox Name="lstBox" Height="200"/> <Button Name="btn" Content="Click" Click="btn_Click"/> </StackPanel> </Window> C# using System.Threading; using System.Threading.Tasks; using System.Windows; namespace AsyncAwait { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void btn_Click(object sender, RoutedEventArgs e) { lstBox.Items.Add("Click()"); Process1(); lstBox.Items.Add("Click() - completed"); } private async void Process1() { lstBox....

January 3, 2019 · 2 min · 333 words · M.Kumaran

Avoid multiple mouse move events in C#

in windows/wpf application, mouse move event is triggered multiple time. We will see how to avoid multiple mouse move events. if we want to do some time consuming task in mouse move event, that will affect the performance. Here we will see how to avoid that using timer. In the below logic, mouse move event will be triggered once the mouse move stopped. XAML <Window x:Class="MouseMoveAvoidMultipleEvents.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Border Name="brd" Background="LightBlue" MouseMove="brd_MouseMove" > </Border> </Window> C# using System; using System....

January 2, 2019 · 1 min · 153 words · M.Kumaran