Shout() public method

Waits for a shout request message to arrive in the Pub/Sub subscription. Converts the text to uppercase and posts the results back to the website.
Nothing more than a wrapper around ShoutOrThrow() to catch unexpected exceptions.
public Shout ( System cancellationToken ) : int
cancellationToken System
return int
コード例 #1
0
 private static void Main(string[] args)
 {
     using (var logWriter = CreateStandardOutputLogWriter())
     {
         var shouter = new Shouter(logWriter);
         while (true)
         {
             shouter.Shout(new System.Threading.CancellationToken());
         }
     }
 }
コード例 #2
0
 protected void ShoutLoop()
 {
     // Configue a LogWriter to write to the Windows Event Log.
     var eventLog = new EventLog("Application", ".", "ShoutService");
     var eventLogTraceListener = new FormattedEventLogTraceListener(eventLog)
     {
         Filter = new SeverityFilter(new TraceEventType[] {
                 TraceEventType.Error, TraceEventType.Information, TraceEventType.Warning})
     };
     var config = new LoggingConfiguration();
     config.AddLogSource("All", SourceLevels.All, true)
       .AddTraceListener(eventLogTraceListener);
     // A using statement ensures the log gets flushed when this process exits.
     using (var logWriter = new LogWriter(config))
     {
         var shouter = new Shouter(logWriter);
         do
         {
             shouter.Shout(cancellationTokenSource.Token);
         } while (!cancellationTokenSource.Token.IsCancellationRequested);
     }
 }