以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]调用钉钉接口之后进程无法关闭  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=184668)

--  作者:81538475
--  发布时间:2022/12/21 18:44:00
--  [求助]调用钉钉接口之后进程无法关闭
try
    Dim client As DingTalk.Api.DefaultDingTalkClient = New DingTalk.Api.DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken")
    Dim request As DingTalk.Api.Request.OapiGettokenRequest = New DingTalk.Api.Request.OapiGettokenRequest()
    request.Appkey = "XXXXX"
    request.Appsecret = "XXXXXXXXX"
    request.SetHttpMethod("GET")
    Dim rsp As DingTalk.Api.Response.OapiGettokenResponse = client.Execute(request)
    Dim result As String = rsp.AccessToken
    Output.Show(result)
Catch ex As Exception
    
End Try

调用接口之后,关闭程序的话,会残留主程序,这种情况应该如何处理呢
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2022/12/22 8:51:00
--  
试试

try
    Dim client As DingTalk.Api.DefaultDingTalkClient = New DingTalk.Api.DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken")
    Dim request As DingTalk.Api.Request.OapiGettokenRequest = New DingTalk.Api.Request.OapiGettokenRequest()
    request.Appkey = "XXXXX"
    request.Appsecret = "XXXXXXXXX"
    request.SetHttpMethod("GET")
    Dim rsp As DingTalk.Api.Response.OapiGettokenResponse = client.Execute(request)
    Dim result As String = rsp.AccessToken
    Output.Show(result)
client =nothing
request=nothing
Catch ex As Exception

End Try

不行的话考虑到项目beforecloseproject事件用kill杀进程吧

--  作者:81538475
--  发布时间:2022/12/22 11:53:00
--  
杀自己的进程怎么写呢


--  作者:有点蓝
--  发布时间:2022/12/22 12:03:00
--  
Dim ps As  System.Diagnostics.Process() = System.Diagnostics.Process.GetProcessesByName("某某进程名称")
For Each p As System.Diagnostics.Process In ps
    p.kill
Next