11.07.2015 Views

y - Net Developer

y - Net Developer

y - Net Developer

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

amrameshreddy.blog.com204 CHAPTER 6 ■ MANAGING WCF SERVICESramrameshreddy.blog.comCreate a new console project called TradingServicePerfMonHost (right-click theWCFManagement solution, and select Add ➤ New Project). You also need to add a reference tothe System.ServiceModel namespace. Put the code in Listing 6-11 in the Program.cs file.Listing 6-11. Code for Program.cs File in TradingServicePerfMonHostusing System;using System.Collections.Generic;using System.Messaging;using System.ServiceModel;using System.Text;namespace ExchangeService{public class Program{public static void Main(string[] args){TradePerfMon trade = new TradePerfMon();using (ServiceHost host = new ServiceHost(typeof(TradePerfMon), new Uri[] { new Uri("http://localhost:8000/TradePerfMonService") })){host.Open();trade.InitializeCounters(host.Description.Endpoints);Console.WriteLine("The WCF Management tradingservice is available.");for (int index = 1; index < 225; index++){Console.WriteLine("IBM - traded " + (index+100) +" shares for " + trade.TradeSecurity("IBM",(index+100)) + " dollars" );// you are deliberately increasing the total volumeof trades to view the difference in thePerfomance Monitor)Console.WriteLine("MSFT - tradedtrade " + index +" shares for " + trade.TradeSecurity("MSFT",index) + " dollars");System.Threading.Thread.Sleep(1000);}}}}}ramrameshreddyramrameshreddyConsole.ReadKey();

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!