Redemption + Clickonce = :-(

前端 未结 3 606
生来不讨喜
生来不讨喜 2021-01-16 11:05

I have a normal windows forms program (Not VSTO) which deploys using click once. The issue is that loads of user are having problems with random errors generally stating (fr

3条回答
  •  佛祖请我去吃肉
    2021-01-16 11:46

    It is entirely possible to use Redemption in background threads, if you do it correctly. The firsr RDOSession object you create, must be created in the UI thread, because some MAPI internals need for the message pump to have been created in the same thread. Typically this RDOSession should be kept for the lifetime of your app. You cannot access this object from any other thread.

    You'll need to pass the MAPIOBJECT property of your first RDOSession to each worker thread, create a new RDOSessuion object from within each thread, and assign the MAPIOBJECT from your RDOSession to the secondary RDOSession created in the thread. Example:

    (Aircode Warning: the code below was typed from memory.)

    Dim PrimaryRDOSession As New Redemption.RDOSession()
    PrimaryRDOSession.Login([...])
    Dim WorkerThread as New System.Threading.Thread(AddressOf ThreadProc)
    WorkerThread.Start(PrimaryRDOSession.MAPIOBJECT)
    
    Sub ThreadProc(ByVal param as Object)
        Dim ThdRDOSession As New Redemption.RDOSession()
        ThdRDOSession.MAPIOBJECT = param
        ' do other stuff
    End Sub
    

    From there you can do anything you'd normally do with Redemption. You can pass EntryIDs between threads if Outlook objects are selected/located in one thread, and acted upon in another.

提交回复
热议问题