Skip to content

Instantly share code, notes, and snippets.

@miteshsureja
miteshsureja / Approver.cs
Created March 13, 2017 05:44
Chain of Responsibility design pattern example
namespace ChainOfResponsibility
{
//Handler class
public abstract class Approver
{
public abstract void HandleRequest(int requestAmount);
protected Approver NextApprover;
public void SetNextApprover(Approver approver)
{
NextApprover = approver;
@miteshsureja
miteshsureja / Program.cs
Created March 8, 2017 14:20
How to handle exception in Parallel.For and Parallel.Foreach loop? – Task Parallel Library
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Concurrent;
namespace ParallelFor
{
class Program
{
static void Main(string[] args)
@miteshsureja
miteshsureja / FileDetails.cs
Created March 8, 2017 14:06
How to find and delete duplicate files from directory using C# code?
using System;
namespace DuplicateFileFinder
{
public class FileDetails
{
public string FileName { get; set; }
public string FileHash { get; set; }
}
}
@miteshsureja
miteshsureja / Program.cs
Created March 8, 2017 13:53
How to cancel a Parallel.For and Parallel.Foreach loop – Task Parallel Library
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System;
using System.Threading.Tasks;
using System.Threading;
namespace ParallelFor
{