dcsimg
Results 1 to 7 of 7

Thread: [RESOLVED] How to stop my application in a loop.

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member shyguyjeff's Avatar
    Join Date
    Jul 2007
    Location
    City of Durian
    Posts
    289

    Resolved [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.

  2. #2
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    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.

  3. #3

    Thread Starter
    Hyperactive Member shyguyjeff's Avatar
    Join Date
    Jul 2007
    Location
    City of Durian
    Posts
    289

    Re: How to stop my application in a loop.

    Quote Originally Posted by keystone_paul View Post
    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.

  4. #4
    Lively Member
    Join Date
    Sep 2008
    Posts
    90

    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...

  5. #5

    Thread Starter
    Hyperactive Member shyguyjeff's Avatar
    Join Date
    Jul 2007
    Location
    City of Durian
    Posts
    289

    Re: How to stop my application in a loop.

    Quote Originally Posted by rheimon View Post
    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?

  6. #6
    Addicted Member Spirited Machine's Avatar
    Join Date
    May 2009
    Posts
    215

    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?

  7. #7
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    102,575

    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
  •  



Featured


Click Here to Expand Forum to Full Width