短信通过Http API发送程序,需要进度条帮助 [英] Sms sending program via Http API.Need help with progress bar

查看:118
本文介绍了短信通过Http API发送程序,需要进度条帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正忙于编写一个程序,该程序用于通过标签为txt的标签文件中的http api发送短信.

我尝试创建一个txtbox并为每个循环添加1,但是尽管在操作完成时它确实在其中显示了一个数字,但短信正在冻结程序并且在那里`` s没有迹象表明发生了任何事情.今天我发送了400条短信,而短信消散所需的5分钟左右时间没有响应.

请注意,我真的是编程的新手,我才2周前才开始编程,为此只是将一些零碎的代码放在一起.所以,如果我的代码真的很糟糕,你会知道为什么.

这是发送代码

Hi am busy putting together a program for sending sms''s via a http api from a tab deliminted txt file.

I tried creating a txtbox and having it add 1 for each loop,but although it does show a number in there when the operation is completed , while the sms''s are going the program just kind of freeze''s and there''s no indication that anything is happening.I sent out 400 sms with it today and it was unresponsive for the 5 or so minutes it took for the sms''s to go out.

Please note I am really new to programing , I only started 2 weeks ago and have kind of just throw bits and pieces of code together for this.So if my code is really bad you know why.

Here''s the code for sending

Dim objFS As New FileStream("c:\data\file.txt", FileMode.Open, FileAccess.Read)
        Dim objSR As New StreamReader(objFS)

        Dim strline, fileline() As String
        Do While (objSR.Peek <> -1)

            strline = objSR.ReadLine
            fileline = strline.Split(vbTab)

            Dim strnum As String = fileline(0)
            Dim strmsg As String = fileline(1)

            Dim request As HttpWebRequest
            Dim response As HttpWebResponse = Nothing

            Dim url As String
            Dim host As String = "http://southafrica.msg91.com"
            Dim senderid As String = "Test"

            Try

                url = host + "/sendhttp.php?" _
                         & "user=" & HttpUtility.UrlEncode(user) _
                         & "&password=" + HttpUtility.UrlEncode(password) _
                         & "&mobiles=" + HttpUtility.UrlEncode(strnum) _
                         & "&message=" + HttpUtility.UrlEncode(strmsg) _
                         & "&sender=" + HttpUtility.UrlEncode(senderid)
                request = DirectCast(WebRequest.Create(url), HttpWebRequest)
                response = DirectCast(request.GetResponse(), HttpWebResponse)

            Catch ex As Exception

                MsgBox(ex.Message)

            End Try

            response.Close()

            Count = Val(txtcnt.Text) + 1
            txtcnt.Text = Count

        Loop



它正在工作,但是有什么方法可以添加某种指示符,以指示它正在发送短信时正在做什么?



It is working , but is there any way of adding some sort of indicator that it is doing something when it''s sending the sms''s?

推荐答案

I通过在后台工作程序中运行代码来解决此问题
I solved this by have the code running in a backround worker


这篇关于短信通过Http API发送程序,需要进度条帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆