本文整理汇总了C#中Subscriber.Start方法的典型用法代码示例。如果您正苦于以下问题:C# Subscriber.Start方法的具体用法?C# Subscriber.Start怎么用?C# Subscriber.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subscriber
的用法示例。
在下文中一共展示了Subscriber.Start方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: buttonValidate
//.........这里部分代码省略.........
rate2 = rates[3];
}
// calculate cost from assigned rates by checking cross referencing start/end times with on/off peak times
if ((IsTimeOfDayBetween(startTime, onpeak, offpeak)) && (IsTimeOfDayBetween(endTime, offpeak, onpeak)))
{
double beforePeak = Convert.ToDouble(offpeak.Hours - startTime.TimeOfDay.Hours);
TravelCost += beforePeak * rate1;
double afterPeak = Convert.ToDouble(endTime.TimeOfDay.Hours - offpeak.Hours);
TravelCost += afterPeak * rate2;
}
else
if ((IsTimeOfDayBetween(startTime, offpeak, onpeak)) && (IsTimeOfDayBetween(endTime, onpeak, offpeak)))
{
double beforePeak = Convert.ToDouble(offpeak.Hours - startTime.TimeOfDay.Hours);
TravelCost += beforePeak * rate2;
double afterPeak = Convert.ToDouble(endTime.TimeOfDay.Hours - offpeak.Hours);
TravelCost += afterPeak * rate1;
}
else
if ((IsTimeOfDayBetween(startTime, onpeak, offpeak)) && (IsTimeOfDayBetween(endTime, onpeak, offpeak)))
{
TravelCost += destTime * rate1;
}
else
TravelCost += destTime * rate2;
#endregion
//
// Price calculation logic
//
#region Message Queue
connectionFactory = new ConnectionFactory(BROKER, CLIENT_ID);
connection = connectionFactory.CreateConnection();
connection.Start();
session = connection.CreateSession();
subscriber = new Subscriber(session, TOPIC_NAME);
subscriber.Start(CONSUMER_ID);
subscriber.OnMessageReceived += new MessageReceivedDelegate(subscriber_OnMessageReceived);
using (var publisher = new Publisher(session, TOPIC_NAME))
{
publisher.SendMessage(TravelCost.ToString());
}
Thread.Sleep(1000);
try
{
subscriber.Dispose();
session.Close();
session.Dispose();
connection.Stop();
connection.Close();
connection.Dispose();
}
catch (Exception ex)
{
lblError.Text = ex.Message.ToString();
}
#endregion
//
// Rebate Processor
//
#region Rebate Processor
// Fetch membership class
conn.Open();