自动重新启动,然后在VB.NET中继续子进程
我有一些潜水艇,比如: 私人Sub somesub() '在1个半小时内达到900 mb的进程 端接头 我想重新启动应用程序,释放内存,然后返回到原来的位置 没错,我有一个添加联系人的应用程序,当添加2000个联系人时,它会达到900mb。。。我想每200个联系人停止一次,并按照我说过的那样做,我没有测试过的代码:自动重新启动,然后在VB.NET中继续子进程,vb.net,restart,skype4com,Vb.net,Restart,Skype4com,我有一些潜水艇,比如: 私人Sub somesub() '在1个半小时内达到900 mb的进程 端接头 我想重新启动应用程序,释放内存,然后返回到原来的位置 没错,我有一个添加联系人的应用程序,当添加2000个联系人时,它会达到900mb。。。我想每200个联系人停止一次,并按照我说过的那样做,我没有测试过的代码: Imports SKYPE4COMLib Public Class frmMain Dim pUser As SKYPE4COMLib.User Dim cont
Imports SKYPE4COMLib
Public Class frmMain
Dim pUser As SKYPE4COMLib.User
Dim contactos As Integer
If contactos < 200 Then
For Each oUser In ListBox1.Items
pUser = oSkype.User(oUser)
pUser.BuddyStatus = SKYPE4COMLib.TBuddyStatus.budPendingAuthorization
oSkype.Friends.Add(pUser)
contactos += 1
Next
Else
'System.Windows.Forms.Application.Restart()
'I need a code that continues where I was, here...
End If
End Sub
End Class
导入SKYPE4COMLib
公开课
Dim pUser作为SKYPE4COMLib.User
Dim contactos作为整数
如果contactos<200,则
对于ListBox1.项中的每个oUser
pUser=oSkype.User(User)
pUser.BuddyStatus=SKYPE4COMLib.TBuddyStatus.buddingAuthorization
oSkype.Friends.Add(pUser)
contactos+=1
下一个
其他的
'System.Windows.Forms.Application.Restart()
“我需要一个代码继续我在这里的位置。。。
如果结束
端接头
末级
我能做什么?谢谢 我在下面编写了一些代码,可以解决您的问题。它当然应该将您的位置保存到一个文件中,然后当文件再次运行时,它将重新加载该位置 几点
Imports SKYPE4COMLib
Public Class frmMain
'Put code here to load position from the file
Dim startingPosition as Integer = 0
If IO.File.Exists("c:\filename.txt")
Using sr as New IO.StreamReader("c:\filename.txt")
sr.Read
StartingPosition = Convert.ToInteger(sr.ReadToEnd)
sr.Close
End Using
End If
'Probably needs some code somewhere to reload your listbox
Dim contactos As Integer
Dim CurrentPosition as Integer = 0
If contactos < 200 and StartingPosition < ListBox1.Items.Count Then
For x as integer = StartingPosition to ListBox1.Items.Count - 1
Dim oUser as <YOURTYPEHERE> = Ctype(ListBox1.Items(x), <YOURTYPEHERE>)
Dim pUser As SKYPE4COMLib.User
pUser = oSkype.User(oUser)
pUser.BuddyStatus = SKYPE4COMLib.TBuddyStatus.budPendingAuthorization
oSkype.Friends.Add(pUser)
contactos += 1
pUser = Nothing 'set the garbage collection to collect this.
CurrentPosition = x
Next
Else
'Save Your place to an external File, all your doing here is opening a file
'and saving the index of where you are in the listbox.
Using sw as New IO.StreamWriter("c:\filename.txt")
sw.Write(CurrentPosition)
sw.Close
End Using
'use the process namespace to have this app start the next copy of your app
'be careful not to use WaitForExit or you will have two copies in memory...
Process.Start("exename")
'or if the command below exists.. use that.. I never have.
'System.Windows.Forms.Application.Restart()
'I need a code that continues where I was, here...
End If
End Sub
End Class
导入SKYPE4COMLib
公开课
'将代码放在此处以从文件加载位置
Dim startingPosition为整数=0
如果IO.File.Exists(“c:\filename.txt”)
使用sr作为新的IO.StreamReader(“c:\filename.txt”)
高级雷德
StartingPosition=转换为Integer(sr.ReadToEnd)
高级关闭
终端使用
如果结束
'可能需要一些代码来重新加载列表框
Dim contactos作为整数
Dim CurrentPosition作为整数=0
如果contactos<200且StartingPosition