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
-- Check the BlkBy column | |
EXEC sp_who2 | |
-- Get all requests that have blocking sessions | |
SELECT * | |
FROM sys.dm_exec_requests | |
WHERE DB_NAME(database_id) = 'YourDBName' | |
AND blocking_session_id <> 0 | |
-- Get the queries themselves |
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
var before0 = GC.CollectionCount(0); | |
var before1 = GC.CollectionCount(1); | |
var before2 = GC.CollectionCount(2); | |
var sw = Stopwatch.StartNew(); | |
// Do... | |
sw.Stop(); |
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
[ServiceContract] | |
public interface IMyService | |
{ | |
[OperationContract] | |
Task DoExpensiveOperation(Guid requestId); | |
[OperationContract(IsOneWay=true)] | |
void CancelExpensiveOperation(Guid requestId); | |
} |
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 forEach(array, asyncAction, callback) { | |
var size = array.length; | |
var count = 0; | |
var nextLoop = true; | |
array.forEach(function (item) { | |
if (nextLoop == true) { | |
asyncAction(item, function (err) { | |
if (err) { | |
nextLoop = false; |
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
// https://lostechies.com/jimmybogard/2008/08/12/enumeration-classes/ | |
public abstract class Enumeration : IComparable | |
{ | |
private readonly int _value; | |
private readonly string _displayName; | |
protected Enumeration() | |
{ | |
} |
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
// References | |
// https://www.visualstudio.com/get-started/package/nuget/publish | |
// https://docs.nuget.org/create/creating-and-publishing-a-package | |
// https://docs.nuget.org/Create/using-a-gui-to-build-packages | |
// Accesing NuGet folder | |
cd {NuGet.exe folder} | |
// Packing from a .csproj file | |
nuget pack {relative file name}.csproj -Prop Configuration=Release |
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
// http://www.codeguru.com/csharp/.net/net_data/sortinganditerating/article.php/c10993/SystemTransactions-Implement-Your-Own-Resource-Manager.htm | |
// https://msdn.microsoft.com/en-us/library/ms229975(v=vs.85).aspx | |
public class VolatileRM : IEnlistmentNotification | |
{ | |
private int memberValue = 0; | |
private int oldMemberValue = 0; | |
public int MemberValue | |
{ |
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
/// <summary> | |
/// Abstraction for an easier Disposable pattern implementation. | |
/// Consumers should override the DisposeManagedObjects and DisposeUnmanagedObjects | |
/// to dispose the desired objects | |
/// </summary> | |
/// <remarks>https://msdn.microsoft.com/pt-br/library/fs2xkftw(v=vs.110).aspx</remarks> | |
public abstract class Disposable : IDisposable | |
{ | |
protected bool disposed = false; |
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
// Basic unitOfWork pattern as described by Martin Fowler (http://martinfowler.com/eaaCatalog/unitOfWork.html) | |
// Other methos as 'registerNew' are going to be managed by each repository | |
public interface IUnitOfWork : IDisposable | |
{ | |
void Commit(); | |
Task CommitAsync(); | |
void Rollback(); | |
} | |
public interface IUnitOfWorkFactory |
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
public interface IObjectValidator<T> | |
{ | |
IEnumerable<ValidationResult> Validate(T @object); | |
} | |
public bool Validate(T objeto, out ICollection<ValidationResult> results) | |
{ | |
var validationResults = new List<ValidationResult>(); | |
// Default validation |
NewerOlder