Skip to content

Instantly share code, notes, and snippets.

View luisdeol's full-sized avatar
🎯
Focusing

Luis Felipe de Oliveira luisdeol

🎯
Focusing
View GitHub Profile
@luisdeol
luisdeol / DataExportClass.cs
Last active May 6, 2024 09:29
Export List of Objects to a Comma-Separated Values (.CSV) file using C#, allowing the export of Entity Framework DbSet to CSV File. An example of use comes within the code.
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace DataExportClass
{
class Program
{
public class Employee
@luisdeol
luisdeol / Program.cs
Last active March 20, 2017 21:40
Simple Console Application to show how to access private fields and their values through Reflection using C#.
using System;
using System.Globalization;
using System.Reflection;
namespace TestingReflection
{
public class Program
{
static void Main(string[] args)
{
@luisdeol
luisdeol / assemblyReferenciesAccess.cs
Created March 20, 2017 22:09
Simple Console Application to show how to access Assembly Referencies of a single Assembly through Reflection using C#.
using System;
using System.Reflection;
namespace TestingReflection
{
public class Program
{
static void Main(string[] args)
{
/* To get access to the PublicKeyToken of an Assembly you need to execute sn.exe and pass the Assembly path.
@luisdeol
luisdeol / Program.cs
Last active November 12, 2017 14:08
Using Tasks
namespace MultiThreadingExamples
{
class Program
{
static void Main(string[] args)
{
Task thePowerfulTask = Task.Run(() =>
{
for (var i = 0; i < 1000; i++)
{
@luisdeol
luisdeol / Program.cs
Created November 12, 2017 13:29
Using the Thread Class
namespace MultiThreadingExamples
{
public static void UltraCoolMethod()
{
const int iterationNumber = 10;
for (var i = 0; i < iterationNumber; i++)
{
Console.WriteLine($"Execution Thread Nº {i}");
Thread.Sleep(0);
}
@luisdeol
luisdeol / Program.cs
Created November 12, 2017 13:31
Foreground and Background Threads
namespace MultiThreadingExamples
{
public static void UltraCoolMethod()
{
const int iterationNumber = 10;
for (var i = 0; i < iterationNumber; i++)
{
Console.WriteLine($"Execution Thread Nº {i}");
Thread.Sleep(0);
}
@luisdeol
luisdeol / Program.cs
Created November 12, 2017 13:33
Using Parametrized ThreadStart
namespace MultiThreadingExamples
{
class ParametrizedThreadStartExample
{
public static void UltraCoolMethod(object o)
{
for (var i = 0; i < (int)o; i++)
{
Console.WriteLine($"Execution Thread Nº {i}");
Thread.Sleep(0);
@luisdeol
luisdeol / Program.cs
Created November 12, 2017 13:34
Using Thread Pools
namespace MultiThreadingExamples
{
class UsingThreadPools
{
static void Main(string[] args)
{
ThreadPool.QueueUserWorkItem((work) =>
{
Console.WriteLine("Luis is trying to do something here...");
});
@luisdeol
luisdeol / Program.cs
Created November 12, 2017 14:13
Using ContinueWith on Tasks
namespace MultiThreadingExamples
{
class Program
{
static void Main(string[] args)
{
Task<string> thePowerfulTaskWithReturn = Task
.Run(() => "Luis is ")
.ContinueWith((firstResult) => firstResult.Result + " sleepy!");
@luisdeol
luisdeol / Program.cs
Created November 12, 2017 14:28
Using WaitAll on Multiple Tasks
namespace MultiThreadingExamples
{
class Program
{
static void Main(string[] args)
{
Stopwatch myStopWatch = new Stopwatch();
Task[] aSetOfTasks = new Task[3];