Posts

Showing posts from January, 2021
Share:

Async Task In C# | Async And Await Keywords | Saatody | Amit Padhiyar

Today we will discuss about async and await keyword. And will know some examples about Task. private async void MyTask() { await Task.Run(() => { // Code Here }); } Avoid use of void. use Task or Task<return_type>. private async Task MyTask() { await Task.Run(() => { // Code Here }); } It can use for non return value. private async Task<int> MyTask() { await Task.Run(() => { // Code Here }); return int; } Returns int values.

Windows 10 IoT Applications With UWP C# | Raspberry Pi | Amit Padhiyar | Saatody

How To Get Removable Devices? Before using this code, You need to enable (check) Removable Storage in Capabilities (in Package.appxmanifest). Warning : Due to async and await keywords, The debugger might not receive some values at breakpoints.  StorageFolder Instance = KnownFolders.RemovableDevices; This how you can get Removable Devices. How To Get List Of Removable Devices? StorageFolder Instance = KnownFolders.RemovableDevices; IReadOnlyList<StorageFolder> Devices = await Instance.GetFoldersAsync(); How To Get Removable Devices By Array Index? Get devices using array index like Devices[0] indicate first device for example "C:", Devices[1] indicate second device for example "D:". If index out of range then it will gives you exception. StorageFolder Instance = KnownFolders.RemovableDevices; IReadOnlyList<StorageFolder> Devices = await Instance.GetFoldersAsync(); StorageFolder Device = Devices[0]; How To Get All Directories And All Files From Current Pat

Number Validation In TextBox WPF | C# | Amit Padhiyar | Saatody

I will create number validation in TextBox. This algorithm only allow numbers while user press any key. TB.PreviewTextInput += (sender, e) => { if (e.Text != "0" && e.Text != "1" && e.Text != "2" && e.Text != "3" && e.Text != "4" && e.Text != "5" && e.Text != "6" && e.Text != "7" && e.Text != "8" && e.Text != "9") { e.Handled = true; } }; Here is little demo on PreviewTextInput. I am researching on validations for TextBox. In future, I will create more detail about it.