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);
}
private void createBtn()
{
Microsoft.Office.Tools.Ribbon.RibbonButton btnStop = this.Factory.CreateRibbonButton();
btnStop.Label = "Stop It";
btnStop.Name = "btnStop";
groupLicense.Items.Add(btnStop);
}
I get exception on below code:
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)).
please provide some solution