-
Jun 2nd, 2009, 02:08 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] How to stop my application in a loop.
Hello everyone... I have something to ask again.. I develop a program that will send bulk messages but the problem is that when I load at least 1000 emails then I want to stop the application I cannot stop it. Is there any way to stop this application without closing the form? So that i can save the file on my listview? Here is my code upon send bulk emails.
Code:
Private Sub frmStatus_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
Dim i As Integer
Dim holder As String
'Dim itemstring As String
Dim LVITem As New ListViewItem
Try
For i = 0 To ListView1.Items.Count - 1
holder = ListView1.Items(i).SubItems(1).Text
sendHTMLmail()
ListView1.Items(i).SubItems(2).Text = carrier
lblCount.Text = i + 1
lblLvwCount.Text = ListView1.Items.Count
SmoothProgressBar2.Value = (i + 1) * 100 / ListView1.Items.Count
Label1.Text = ((i + 1) * 100 / ListView1.Items.Count).ToString("N", nfi) + "%"
Next
btnLog.Visible = True
btnStop.Enabled = True
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
One problem I encountered also is that once the mail started to send and the user will click my listview my application will stop sending and I cannot stop the application anymore so if this happen I end up the application by using the stop in a task manager. Anyone can help me to this? Thanks in advance and have a nice day.
Last edited by shyguyjeff; Jun 2nd, 2009 at 10:49 PM.
-
Jun 2nd, 2009, 02:27 AM
#2
Re: How to stop my application in a loop.
Hmm... you may find people reticent to help you with a program for automatically sending out thousands of e-mails .
I assume that you have a copy and paste error in your frmStatus.Shown event as you have an "Else If" statement without an "If" preceding it.
-
Jun 2nd, 2009, 02:38 AM
#3
Lively Member
Re: How to stop my application in a loop.
put a counter in your codes and increment it every time you send an email, then when counter >1000 you will stop sending, or do you want to stop by hitting a button?
PL:VB2008 
LEVEL: beginner
There must be a simpler way to do this...
-
Jun 2nd, 2009, 04:57 AM
#4
Thread Starter
Hyperactive Member
Re: How to stop my application in a loop.
 Originally Posted by keystone_paul
Hmm... you may find people reticent to help you with a program for automatically sending out thousands of e-mails .
I assume that you have a copy and paste error in your frmStatus.Shown event as you have an "Else If" statement without an "If" preceding it.
I edited my code now paul. Is it the right place paul to put my code in my frmStatus.shown upon sending? Once I started the mail then it won't stop.
Last edited by shyguyjeff; Jun 2nd, 2009 at 10:50 PM.
-
Jun 9th, 2009, 11:18 PM
#5
Thread Starter
Hyperactive Member
Re: How to stop my application in a loop.
 Originally Posted by rheimon
put a counter in your codes and increment it every time you send an email, then when counter >1000 you will stop sending, or do you want to stop by hitting a button?
I want to stop by hitting the button.... How can I do that?
-
Jun 9th, 2009, 11:25 PM
#6
Addicted Member
Re: How to stop my application in a loop.
Have the stop button set i equal to whatever is necessary to stop the for loop?
-
Jun 9th, 2009, 11:54 PM
#7
Re: How to stop my application in a loop.
Use a BackgroundWorker. Follow the CodeBank link in my signature and you'll find my submission on the subject, which demonstrates how to update the UI and also how to cancel the background operation.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|