Vb.net 在线程中打开和关闭单词

Vb.net 在线程中打开和关闭单词,vb.net,multithreading,document,Vb.net,Multithreading,Document,当一个文档被下载到一个特定的文件夹中时,使用filesystemwatcher,我会在一个线程中打开这个word文档,这很好。我正在打开一个文档,如下所示 Private Sub watcher_Created(sender As Object, e As FileSystemEventArgs) Try DocWatcher.EnableRaisingEvents = False ThreadPool.QueueUserWorkItem(

当一个文档被下载到一个特定的文件夹中时,使用filesystemwatcher,我会在一个线程中打开这个word文档,这很好。我正在打开一个文档,如下所示

Private Sub watcher_Created(sender As Object, e As FileSystemEventArgs)
    Try

        DocWatcher.EnableRaisingEvents = False
        ThreadPool.QueueUserWorkItem(
                                    Sub(process)
                                        OpenWord(e.FullPath)
                                    End Sub
                                )

    Catch ex As Exception
        MsgBox(ex.Message)
    Finally
        DocWatcher.EnableRaisingEvents = True
    End Try   

end sub
   sub OpenWord(byval Path as string)
        // open document here
   End sub   
当文档关闭时,有人能帮我找到如何捕获关闭事件、清除word对象(word.application)和清除该线程吗


我是这个vb.net的新手,花了很多晚上来解决这个问题

你正在使用进程。开始运行Word吗?不,David。只是正常地打开它正常地是什么?你能为它添加代码吗:)WordApp=newWord.Application WordDoc=WordApp.Documents.Open(路径)