首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

高手来看一下,代码有关问题

2012-03-01 
高手来看一下,代码问题为什么下面的代码,一步一步运行发短信不会有问题但全部一起运行就会出错publicstrin

高手来看一下,代码问题
为什么下面的代码,一步一步运行发短信不会有问题
但全部一起运行就会出错
public   string   SendMessage(string   centerNumber,string   number,string   message)
                {
                        string   str;
                        string   temp;  
   
                        PDUdecoding   pdu   =   new   PDUdecoding();
                      //短信中心号编码
                        string   s     =   pdu.smsDecodedCenterNumber(centerNumber);
                      //接受手机号编码
                        string   s1   =   pdu.smsDecodedNumber(number);
                      //整个短信编码
                        string   s2   =   pdu.smsDecodedsms(centerNumber,   number,message);
                        int   leng   =   (s2.Length   -   s.Length)/2;
                       
                        str   =   "AT+CMGF=0 "   +   '\r ';
                   
                        comm.Output   =   str;
                        System.Threading.Thread.Sleep(1000);
 
                        temp   =   string.Format( "AT+CMGS={0} ",leng);
                        str   =   temp   +   '\r ';
                     
                        comm.Output   =   str;
                        System.Threading.Thread.Sleep(1000);
                   
                        str   =   s2+   '\u001a ';
                   
                        comm.Output   =   str;
                        System.Threading.Thread.Sleep(1000);
                        return   " ";
                }
 
 
                        //打开串口
  在                   InitComPort();


                        string[]   number   =   new   string[]   {   "13072815383 ", "13518166563 ", "13730889586 "};
                        for   (int   i   =   0;   i   <   number.Length;   i++)
                        {
                                test.SendMessage( "8613010811500 ",   number[i],   this.textBox1.Text);
                        }

[解决办法]
中间延迟的时间不足
[解决办法]
短信发送一条,中间应该要一些时间停顿的,你这样连着发一定会出问题的

热点排行