zoukankan      html  css  js  c++  java
  • vb 纵一苇之所如

      Public Sub DeownloadFile(ByVal networkfile As String, ByVal locationFileName As String, ByVal PaperDownloadLog As String, ByVal strReferer As String)
            For index = 1 To 3 '如获取不了重试3次
                Dim task As NewTaskDelegate = AddressOf TrytoDownloadFile
                Dim asyncResult As IAsyncResult = task.BeginInvoke(networkfile, locationFileName, PaperDownloadLog, strReferer, Nothing, Nothing)
                Dim marktime As Integer = 0
                While Not asyncResult.IsCompleted And marktime < 30 '五分钟内未完成就跳过
                    marktime += 1
                    'MessageBox.Show("还没完成?那我先sleep" & marktime)
                    Threading.Thread.Sleep(1000)
                End While
                Dim result As Integer = task.EndInvoke(asyncResult)
                If result > 0 Then Exit For


            Next

            'Dim result As Integer = task.EndInvoke(asyncResult)
            'MessageBox.Show(result.ToString())
        End Sub


        Private Delegate Function NewTaskDelegate(ByVal networkfile, ByVal locationFileName, ByVal PaperDownloadLog, ByVal strReferer) As Integer
        Public Function TrytoDownloadFile(ByVal networkfile As String, ByVal locationFileName As String, ByVal PaperDownloadLog As String, ByVal strReferer As String)
          

      Public Sub DeownloadFile(ByVal networkfile As String, ByVal locationFileName As String, ByVal PaperDownloadLog As String, ByVal strReferer As String)
            For index = 1 To 3 '如获取不了重试3次
                Dim task As NewTaskDelegate = AddressOf TrytoDownloadFile
                Dim asyncResult As IAsyncResult = task.BeginInvoke(networkfile, locationFileName, PaperDownloadLog, strReferer, Nothing, Nothing)
                Dim marktime As Integer = 0
                While Not asyncResult.IsCompleted And marktime < 30 '五分钟内未完成就跳过
                    marktime += 1
                    'MessageBox.Show("还没完成?那我先sleep" & marktime)
                    Threading.Thread.Sleep(1000)
                End While
                Dim result As Integer = task.EndInvoke(asyncResult)
                If result > 0 Then Exit For
    
    
            Next
    
            'Dim result As Integer = task.EndInvoke(asyncResult)
            'MessageBox.Show(result.ToString())
        End Sub
    
    
        Private Delegate Function NewTaskDelegate(ByVal networkfile, ByVal locationFileName, ByVal PaperDownloadLog, ByVal strReferer) As Integer
        Public Function TrytoDownloadFile(ByVal networkfile As String, ByVal locationFileName As String, ByVal PaperDownloadLog As String, ByVal strReferer As String)
           
    
  • 相关阅读:
    C#读写INI配置文件(转)
    关于DBNull
    XNA项目运行错误:No suitable graphics card found.
    C#3.0新增特性
    Windows 8 Metro开发疑难杂症(三)——导航(2),数据保存,数据虚拟化
    Windows 8 Metro开发疑难杂症(一)——导航
    windows 8 metro 风格开发(7)发布一个常用控件类库
    Windows 8 Metro开发疑难杂症(四)——(伪)数据库
    windows 8 metro 风格开发(9)Interactive(Behavior和EventTrigger)
    Windows 8 Metro开发疑难杂症(六)——APP的挂起状态
  • 原文地址:https://www.cnblogs.com/panjinzhao/p/3127095.html
Copyright © 2011-2022 走看看