当前位置: 首页>>代码示例>>C#>>正文


C# Service.stopService方法代码示例

本文整理汇总了C#中Service.stopService方法的典型用法代码示例。如果您正苦于以下问题:C# Service.stopService方法的具体用法?C# Service.stopService怎么用?C# Service.stopService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Service的用法示例。


在下文中一共展示了Service.stopService方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: set

        public void set(string gateway_name,int port,byte[] b_ip,string s_ip)
        {     
            srv = Service.getInstance();
            com1 = new Comm2IP.Comm2IP(b_ip, port, modem.AttachedTo , 115200); //modem comport

            try
            {
                new Thread(new ThreadStart(com1.Run)).Start();

                IPModemGateway gateway = new IPModemGateway(gateway_name, s_ip, port, "Huawei", "");

                gateway.setIpProtocol(ModemGateway.IPProtocols.BINARY);
                gateway.setProtocol(AGateway.Protocols.PDU);
                gateway.setInbound(true);
                gateway.setOutbound(true);
                gateway.setSimPin("0000");

                srv.addGateway(gateway);

                // Start! (i.e. connect to all defined Gateways)
                srv.startService();

                // Send more than one message at once.
                OutboundMessage[] msgArray = new OutboundMessage[contact_list.Count];
                int count = 0;

                foreach (int number in contact_list)
                {
                    msgArray[count++] = new OutboundMessage(number.ToString(), sms.Content);
                }

                srv.sendMessages(msgArray);

                //Console.WriteLine(msgArray[0]);
                //Console.WriteLine(msgArray[1]);

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Console.Read();
            }
            finally
            {
                com1.Stop();
                srv.stopService();
            }
        }
开发者ID:sbpallekumbura,项目名称:LoanManagementSystem,代码行数:49,代码来源:SMSSender.cs

示例2: DoIt

        public void DoIt()
        {
            // Create new Service object - the parent of all and the main interface to you.

            srv = Service.getInstance();

            // *** The tricky part ***
            // *** Comm2IP Driver ***
            // Create (and start!) as many Comm2IP threads as the modems you are using.
            // Be careful about the mappings - use the same mapping in the Gateway definition.
            Comm2IP.Comm2IP com1 = new Comm2IP.Comm2IP(new byte[] { 127, 0, 0, 1 }, 12000, "com20", 115200);

            try
            {
                //Console.WriteLine("");
                Console.WriteLine("Library Version: " + Library.getLibraryVersion());
                Console.WriteLine("Please wait while server is initialising...");
                // Start the COM listening thread.
                new Thread(new ThreadStart(com1.Run)).Start();
                Console.Write("||");
                // Lets set some callbacks.
                srv.setInboundMessageNotification(new InboundNotification());
                Console.Write("||");
                //srv.setOutboundMessageNotification(new OutboundNotfication());
                Console.Write("||");
                //srv.setCallNotification(new CallNotification());
                srv.setGatewayStatusNotification(new GatewayStatusNotification());
                Console.Write("||");

                // Create the Gateway representing the serial GSM modem.
                // Due to the Comm2IP bridge, in SMSLib for .NET all modems are considered IP modems.
                IPModemGateway gateway = new IPModemGateway("modem.com20", "127.0.0.1", 12000, "Huawei", "E220");
                Console.Write("||");
                gateway.setIpProtocol(ModemGateway.IPProtocols.BINARY);
                Console.Write("||");
                // Set the modem protocol to PDU (alternative is TEXT). PDU is the default, anyway...
                gateway.setProtocol(AGateway.Protocols.PDU);
                Console.Write("||");
                // Do we want the Gateway to be used for Inbound messages?
                gateway.setInbound(true);
                Console.Write("||");
                // Do we want the Gateway to be used for Outbound messages?
                gateway.setOutbound(true);

                Console.Write("||");
                // Let SMSLib know which is the SIM PIN.
                gateway.setSimPin("0000");
                Console.Write("||");
                //This Smsc number is of warid. Adjust accordingly
                //only use for sms sending pourose.
                gateway.setSmscNumber("+923210006001");
                Console.Write("||");
                // Add the Gateway to the Service object.
                srv.addGateway(gateway);
                Console.Write("||");
                // Similarly, you may define as many Gateway objects, representing
                // various GSM modems, add them in the Service object and control all of them.
                Console.Write("||");
                // Start! (i.e. connect to all defined Gateways)
                srv.startService();
                Console.WriteLine();
                Console.WriteLine("Modem Information:");
                Console.WriteLine("  Manufacturer: " + gateway.getManufacturer());
                Console.WriteLine("  Model: " + gateway.getModel());
                Console.WriteLine("  Serial No: " + gateway.getSerialNo());
                Console.WriteLine("  SIM IMSI: " + gateway.getImsi());
                Console.WriteLine("  Signal Level: " + gateway.getSignalLevel() + "dBm");
                Console.WriteLine("  Battery Level: " + gateway.getBatteryLevel() + "%");

                Console.WriteLine();
                Console.WriteLine("Press <ENTER> to terminate...");
                Console.In.ReadLine();
            }
            catch (Exception e)
            {
            Console.WriteLine("Some thing went wrong here");
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
            finally
            {
                com1.Stop();
                srv.stopService();
            }
        }
开发者ID:nuces-acm,项目名称:DevFest-12-Team-4,代码行数:85,代码来源:ReadMessages.cs


注:本文中的Service.stopService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。