This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Before C# 13 | |
Console.WriteLine("\u001b[31mThis is red text\u001b[0m"); | |
// With C# 13 | |
Console.WriteLine("\e[31mThis is red text\e[0m"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
class LockingDemo | |
{ | |
private static System.Threading.Lock lock = new(); | |
static void Main() | |
{ | |
PerformSafeOperation(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private System.Threading.Lock _lock = new(); | |
void Update() | |
{ | |
lock (_lock) | |
{ | |
// safely synchronized | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private readonly object _lock = new(); | |
void Update() | |
{ | |
lock (_lock) | |
{ | |
// critical section | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Log(params MyCustomLogCollection logs) | |
{ | |
foreach (var log in logs) | |
Console.WriteLine(log); | |
} | |
public class MyCustomLogCollection : IEnumerable<string> | |
{ | |
private readonly List<string> _logs = new(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Print(params Span<int> values) | |
{ | |
foreach (var value in values) | |
Console.WriteLine(value); | |
} | |
Span<int> span = stackalloc int[] { 10, 20, 30 }; | |
Print(span); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void PrintNumbers(params int[] numbers) | |
{ | |
foreach (var number in numbers) | |
Console.WriteLine(number); | |
} | |
var myList = new List<int> { 1, 2, 3 }; | |
PrintNumbers(myList.ToArray()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[FunctionName("FlowCleanupOrchestratorTimeTrigger")] | |
public async Task Run([TimerTrigger("%FlowCleanupTimeTrigger%", RunOnStartup = true)] TimerInfo myTimer, | |
[DurableClient] IDurableOrchestrationClient client) | |
{ | |
var instanceId = Guid.NewGuid().ToString(); | |
try | |
{ | |
_logger.LogInformation($"FlowCleanupOrchestratorTimeTrigger Timer trigger function activated for instanceId: {instanceId}"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Function("FlowCleanupOrchestratorTimeTrigger")] | |
public async Task Run([TimerTrigger("%FlowCleanupTimeTrigger%", RunOnStartup = true)] TimerInfo myTimer, | |
[DurableClient] DurableTaskClient client) | |
{ | |
var instanceId = Guid.NewGuid().ToString(); | |
try | |
{ | |
_logger.LogInformation($"FlowCleanupOrchestratorTimeTrigger Timer trigger function activated for instanceId: {instanceId}"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Function(nameof(ExportOrchestrator))] | |
public async Task<string> RunOrchestrator([OrchestrationTrigger] TaskOrchestrationContext context) | |
{ | |
try | |
{ | |
// Handling business logic | |
// ... | |
var entityId = new EntityInstanceId(nameof(ExportProcessState), entityKey); |
NewerOlder