A place for App developers to hang out / post
-
brianlich
- Posts: 34
- Joined: Wed Jun 08, 2011 1:49 am
- Location:
-
HTPC Specs:
-
-
#1
Post
by brianlich » Tue Nov 19, 2013 4:31 am
I have a dialog box with a few buttons. When I click on a button, I'd like to navigate to a MCML page. Unfortunately, it tells me I need to be on the application thread. Is it possible to get back to it?
I'm using a callback, which I think is not run on the application thread. I'm trying to navigate back to the MCML page from within the callback when I get the error.
Here's some of the code.
The callback:
Code: Select all
public void ScrollItemDialogCallback(Microsoft.MediaCenter.DialogResult result)
{
switch (result.ToString().ToUpper())
{
case "100":
this.GoToPage();
break;
case "101":
this.Remove();
break;
default:
break;
}
}
The code I'm using to try to get to the page:
Code: Select all
public void GoToPage()
{
Dictionary<string, object> properties = new Dictionary<string, object>();
properties["Application"] = this;
if (session != null)
{
session.GoToPage("resx://addin/addin.Resources/Page", properties);
}
else
{
Debug.WriteLine("GoToPage");
}
}
-
sccrgoalie1
- Posts: 317
- Joined: Fri Jul 08, 2011 5:52 pm
- Location:
-
HTPC Specs:
-
CPU: Intel Core i3
Mobo: Intel DH67BL
RAM: 24 GB
HDD: 2 TB
GPU: Intel Integrated Graphics
Tuner: 2 x HD Homerun Prime
Case: Antec 1200
Remote: Logitech Harmony 900
Display: Panasonic 52 inch plasma
Amp: Pioneer VSX-TSX
TV Provider: Charter
-
#2
Post
by sccrgoalie1 » Tue Nov 19, 2013 2:09 pm
brianlich wrote:I have a dialog box with a few buttons. When I click on a button, I'd like to navigate to a MCML page. Unfortunately, it tells me I need to be on the application thread. Is it possible to get back to it?
I'm using a callback, which I think is not run on the application thread. I'm trying to navigate back to the MCML page from within the callback when I get the error.
Here's some of the code.
The callback:
Code: Select all
public void ScrollItemDialogCallback(Microsoft.MediaCenter.DialogResult result)
{
switch (result.ToString().ToUpper())
{
case "100":
this.GoToPage();
break;
case "101":
this.Remove();
break;
default:
break;
}
}
The code I'm using to try to get to the page:
Code: Select all
public void GoToPage()
{
Dictionary<string, object> properties = new Dictionary<string, object>();
properties["Application"] = this;
if (session != null)
{
session.GoToPage("resx://addin/addin.Resources/Page", properties);
}
else
{
Debug.WriteLine("GoToPage");
}
}
Take a look at Application.DeferredInvoke and Application.DeferredInvokeonWorkerThread
-
sccrgoalie1
- Posts: 317
- Joined: Fri Jul 08, 2011 5:52 pm
- Location:
-
HTPC Specs:
-
CPU: Intel Core i3
Mobo: Intel DH67BL
RAM: 24 GB
HDD: 2 TB
GPU: Intel Integrated Graphics
Tuner: 2 x HD Homerun Prime
Case: Antec 1200
Remote: Logitech Harmony 900
Display: Panasonic 52 inch plasma
Amp: Pioneer VSX-TSX
TV Provider: Charter
-
#3
Post
by sccrgoalie1 » Tue Nov 19, 2013 4:27 pm
And here's an example
Code: Select all
public void NavigateSearchByTitleAndDescription()
{
isBusy = true;
Microsoft.MediaCenter.UI.Application.DeferredInvokeOnWorkerThread(new DeferredHandler(rpMediaCenter.Potatoes[0].ConnectForSearch), new DeferredHandler(NavigateSearchByTitleAndDescriptionDeferred), new object[1]);
}
public void NavigateSearchByTitleAndDescriptionDeferred(object oargs)
{
Dictionary<string, object> properties = new Dictionary<string, object>();
properties["SearchListings"] = mSearchListings;
isBusy = false;
session.GoToPage("resx://SharedGuidePotato/SharedGuidePotato.Resources/SearchListings", properties);
}
-
brianlich
- Posts: 34
- Joined: Wed Jun 08, 2011 1:49 am
- Location:
-
HTPC Specs:
-
-
#4
Post
by brianlich » Tue Nov 19, 2013 5:36 pm
Thanks!