none
multithreadin in c#, VSTO

    Question

  • I have a task to provide a button to stop running process and for that sake i am trying to use multithreading but it gave me exception on a certain point i don't understand how to deal with it please provide some solution. Here its code

    private void btngenerateNew_Click(object sender, RibbonControlEventArgs e)
        {
            ThreadObject threadObj = new ThreadObject();
            threadObj.sender = sender;
            threadObj.e = e;
            btnGen = new Thread(supportCall);
            btnGen.Start(threadObj);
        }
        private void callGeneateBtn(ThreadObject threadObject)
        {
            btngenerate_Click(threadObject.sender,threadObject.e);
        }
        private void supportCall(object parameter)
        {
            ThreadObject ob = parameter as ThreadObject;
            callGeneateBtn(ob);
        }
     public string FetchSelectedProperty(string propertyType, string typeStr, ref Microsoft.Office.Interop.Word._Document document)
        {
            string strPropValue = string.Empty;
            DocumentProperties properties;
            properties = (DocumentProperties)document.CustomDocumentProperties;
            object missing = System.Reflection.Missing.Value;

    here its throwing the exception Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Core.DocumentProperties'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{2DF8D04D-5BFA-101B-BDE5-00AA0044DE52}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

    Tuesday, May 26, 2015 10:40 AM