I have code which sends a file to a client & on another side I'm receiving it using ContentAdded event. That event gets raised but CanInvoke is returning false. Where I'm getting wrong?

void _sharingModality_ContentAdded(object sender, ContentCollectionChangedEventArgs e)
    {
        if (e.Item.Type == ShareableContentType.NativeFile)
        {
            int hr;
            if (e.Item.CanInvoke(ShareableContentAction.DownloadFile, out hr))
            {
                MessageBox.Show("download event raised");
            }
            else
            {
                MessageBox.Show("u cannot invoke download");
            }
        }
    }

Thanks!

(Note: I'm using Lync client 2013)

EDIT 1:

CanInvoke returns true if I put a message box before that statement, otherwise returns false. Is it affecting some background thread or something?

有帮助吗?

解决方案

Got the answer. The state of ShareableContent that is our file is Connecting while I'm firing CanInvoke on it. The file can only be downloaded when state changes to Online. So by handling ShareableContent.StateChanged event I made it work. So simple but took so much time because of very poor documentation.

MSDN reference here..

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top