My sample application to understand the usage of BlockingCollections and its purpose:
Download sample
Another application borrowed from the internet:
Download
ProfileList := {}
ProfileCount = 2
Loop, % ProfileCount
ProfileList[A_Index] := {}
ProfileList.1.Name := "MyName"
ProfileList.1.Password := "MyPassword"
ProfileList.1.Server := "TheServer"
ProfileList.2.Name := "AnotherName"
ProfileList.2.Password := "AnotherPassword"
ProfileList.2.Server := "AnotherServer"
for each, item in ProfileList
{
MsgBox, % "Name: " item.name "`nPassword: " item.Password "`nServer: " item.server
}
*Pub-sub mechanism in an LOB application //QueryProviders class MutualFundOrderProvider { private Dictionary<string,string> GetKeyValues(MutualFundOrderInfo info) { ... } } class GICOrderProvider { private Dictionary<string,string> GetKeyValues(GICOrderInfo info) { ... } } class EquityOrderProvider { private Dictionary<string,string> GetKeyValues(EquityOrderInfo info) { ... } } //visitor approach //Create interface interface IKeyValueComputer { Dictionary<string,string> GetKeyValues(EquityOrderInfo info); Dictionary<string,string> GetKeyValues(GICOrderInfo info); Dictionary<string,string> GetKeyValues(MutualFundOrderInfo info) } //implementation class KeyValueComputer:IKeyValueComputer { //all implementations... } //another interface interface IComputeKeyValues { Dictionary<string,string> ComputeKeyValues(IKeyValueComputer keyvalcomp) } class EquityOrderInfo: IComputeKeyValues { public Dictionary<string,string> ComputeKeyValues(IKeyValueComputer keyvalcomp) { return keyvalcomp.GetKeyValues(this); } } //MutualFundOrderProvider class MutualFundOrderProvider { public void Translate(MutualFundOrderInfo info) { IKeyValueComputer keyvalcomp=new KeyValueComputer(); info.ComputeKeyValues(keyvalcomp); } }
//view model public void GetEmployees() { var emp = ServiceFactory.GetService<IEmployeeService>(); } //IServiceFactory public interface IServiceFactory { T GetService<T>(); } //ServiceFactory class public static class ServiceFactory: IServiceFactory { public T GetService<T>() { T svc = default(T); ChannelFactory<T> factory = new ChannelFactory<T>(typeof(T).FullName); //any other logic or conditions you want //... svc = factory.CreateChannel(); return svc; } }
private TaskProcessor _current; public void AddTaskInQueue(string taskName, Action<object> action, object state, int priority) TaskProcessor.Current.AddTaskInQueue("SomeTaskName", action => private TaskProcessor _taskprocessor; public class TaskSynchronizationContext : SynchronizationContext TaskProcessor.Current.AddTaskInQueue("SomeTaskName", action => using System; public static class LogManager public static void LogEntity(LogCategory category, LogPriority priority, object valueToLog, string logMessage) <logFilters> //Inside EmployeeManager.cs public static T RetrieveItem<T>(string policy, string keyname) public class SlidingExpCacheProvider: BaseCacheProvider