Skip to content

Instantly share code, notes, and snippets.

@kip9000
kip9000 / Task Based asynchrony
Created October 14, 2013 12:59
C# Async Operations Notes
How to create an asynchronous task
var t = Task.Run(() =>
{
//Long Running Task
});
var t1 = t.ContinueWith(tt =>
{
Console.WriteLine("Ran to Completion successfully. i.e. no cancellation or faulting happened");
@kip9000
kip9000 / Cryptor.cs
Last active June 23, 2020 14:25
How to encrypt and decrypt a file using AESManaged API
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace Cryptor
{
@kip9000
kip9000 / Capture1.PNG
Last active December 21, 2015 05:28
WPF Async Operations reporting Progress and Cancelling
Capture1.PNG
@kip9000
kip9000 / Scripting Support for WPF App.cs
Last active January 12, 2017 16:51
Add IronPython scripting to your WPF app using VS2012/.Net4.5
Steps:
1. Create a new WPF App in VS2012
2. Add NuGet packages IronPython, and IronPython Stdlib
3. Setup ScriptEngine (see code)
4. Create the Controller (MVC) for data binding. (see code)
5. Run app, put some python code to TextBox hit Run Script
XAML:
------
@kip9000
kip9000 / gist:4201912
Created December 4, 2012 08:46
convert std::string to integer in C++
int i3;
std::stringstream(record[i]) >> i3;
@kip9000
kip9000 / Set Custom Cursor in a WPF Application
Created December 4, 2012 08:43
Set Custom Cursor in a WPF Application
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Mouse.OverrideCursor = CreateCursor(50,50, Brushes.Gold, null);
}
Cursor CreateCursor(double rx, double ry, SolidColorBrush brush, Pen pen)