
Originally Posted by
hamishwillee
Moving from WP7 (173 x 173) to WP8 (691x336 + 336x336 + 159x159) is about 12x the amount of pixel data. If you're not being efficient with your code then obviously any problems are far more likely to show up. Unfortunately there is no way to debug this without code.
I suggest you have a close look at your running code, perhaps with the aid of memory analysis tools:
http://www.developer.nokia.com/Commu..._Windows_Phone . Start by just creating the minimum and seeing what it is that actually breaks everything. There are useful topics in the
optimisation category which might help too.
In addition, provide (buildable) code sample so that people here can debug more effectively.
(Thanks to Vaughan Knight for advice on this)
Thanks for reply This my complete section of code that responsible for updating live tile
Code:
protected override async void OnInvoke(ScheduledTask task)
{
if (DeviceNetworkInformation.IsNetworkAvailable) //Replace this with winRT API
{
tileHelper = new TileHelper();
_settingsService = new AppSettings();
rateTriggerService = new RateTriggeringService();
rateTrigger = new RateTrigger();
exchangeRate = new ExchangeRate();
_exchangeRateService = new OnLineExchangeRates(exchangeRatesURL);
var countryName = _settingsService.GetValueOrDefault<string>("Country", "United Arab Emirates");
IList<ExchangeRate> list = await _exchangeRateService.GetExchangeRates(Utilities.GetCountryCode(countryName).ToLower());
rateTrigger = await rateTriggerService.LoadAsync();
string selectedCurrency = rateTrigger.Currency;
foreach (ExchangeRate item in list)
{
if (item.Currency == selectedCurrency)
{
exchangeRate = item;
break;
}
}
if (exchangeRate != null)
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
UpdateTile(exchangeRate, DateTime.Now);
});
}
}
}
public void UpdateTile(ExchangeRate item, DateTime lastUpdateDate)
{
if (item == null)
return;
//Create medium image & wait until opened
_medImage = new BitmapImage(new Uri("Assets/Tiles/TileBackgroundMedium.png", UriKind.Relative));
_medImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
EventHandler<RoutedEventArgs> MedImageOpenedHandler = null;
MedImageOpenedHandler = (s, e) =>
{
_medImage.ImageOpened -= MedImageOpenedHandler;
//Create wide image & wait until opened
_wideImage = new BitmapImage(new Uri("Assets/Tiles/TileBackgroundLarge.png", UriKind.Relative));
_wideImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
EventHandler<RoutedEventArgs> WideImageOpenedHandler = null;
WideImageOpenedHandler = (s1, e1) =>
{
_wideImage.ImageOpened -= WideImageOpenedHandler;
UpdateTileImages(item, lastUpdateDate);
};
_wideImage.ImageOpened += WideImageOpenedHandler;
};
_medImage.ImageOpened += MedImageOpenedHandler;
}
private async void UpdateTileImages(ExchangeRate item, DateTime lastUpdateDate)
{
//1. Medium tile
var medImage = new Image { Source = _medImage };
var medBmp = new WriteableBitmap(336, 336);//Medium tile size
medBmp.Render(medImage, null);
//Currency
var txtCurrency1 = new TextBlock();
txtCurrency1.FontSize = 32;
txtCurrency1.FontWeight = FontWeights.Bold;
txtCurrency1.Text = item.Currency;
txtCurrency1.Foreground = new SolidColorBrush(Colors.Black);
medBmp.Render(txtCurrency1, new TranslateTransform() { X = 20, Y = 30 });
//FC Buy
var txtFCBuy1 = new TextBlock();
txtFCBuy1.FontSize = 32;
txtFCBuy1.FontWeight = FontWeights.Bold;
txtFCBuy1.Text = "FC Buy : ";
txtFCBuy1.Foreground = new SolidColorBrush(Colors.Black);
medBmp.Render(txtFCBuy1, new TranslateTransform() { X = 20, Y = 100 });
//FC Buy value
var txtFCBuyValue1 = new TextBlock();
txtFCBuyValue1.FontSize = 32;
txtFCBuyValue1.FontWeight = FontWeights.Normal;
txtFCBuyValue1.Text = item.FCBuy.ToString();
txtFCBuyValue1.Foreground = new SolidColorBrush(Colors.Black);
medBmp.Render(txtFCBuyValue1, new TranslateTransform() { X = 150, Y = 100 });
//FC Sell
var txtFCSell1 = new TextBlock();
txtFCSell1.FontSize = 32;
txtFCSell1.FontWeight = FontWeights.Bold;
txtFCSell1.Text = "FC Sell : ";
txtFCSell1.Foreground = new SolidColorBrush(Colors.Black);
medBmp.Render(txtFCSell1, new TranslateTransform() { X = 20, Y = 150 });
//FC Sell Value
var txtFCSellValue1 = new TextBlock();
txtFCSellValue1.FontSize = 32;
txtFCSellValue1.FontWeight = FontWeights.Normal;
txtFCSellValue1.Text = item.FCSell.ToString();
txtFCSellValue1.Foreground = new SolidColorBrush(Colors.Black);
medBmp.Render(txtFCSellValue1, new TranslateTransform() { X = 150, Y = 150 });
//Last update
var txtLastUpdate1 = new TextBlock();
txtLastUpdate1.FontSize = 24;
txtLastUpdate1.FontWeight = FontWeights.Normal;
txtLastUpdate1.Text = DateTime.Now.ToString();
txtLastUpdate1.Foreground = new SolidColorBrush(Colors.Black);
medBmp.Render(txtLastUpdate1, new TranslateTransform() { X = 20, Y = 250 });
medBmp.Invalidate();
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
var filename = "/Shared/ShellContent/TileBackgroundMedium.jpg";
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
if (myIsolatedStorage.FileExists(filename))
{
myIsolatedStorage.DeleteFile(filename);
}
IsolatedStorageFileStream fileStream = myIsolatedStorage.CreateFile(filename);
medBmp.SaveJpeg(fileStream, 336, 336, 0, 100);
fileStream.Close();
fileStream.Dispose();
}
}
medBmp = null;
UpdateTileData();
}
private void UpdateTileData()
{
if (_useMainTile)
{
FlipTileData tileData = new FlipTileData()
{
BackBackgroundImage = new Uri("isostore:" + "/Shared/ShellContent/TileBackgroundMedium.jpg", UriKind.RelativeOrAbsolute),
//WideBackBackgroundImage = new Uri("isostore:" + "/Shared/ShellContent/TileBackgroundLarge.jpg", UriKind.RelativeOrAbsolute)
};
ShellTile mainTile = ShellTile.ActiveTiles.FirstOrDefault();
QueryMemory("Device Current Memory before update ");
mainTile.Update(tileData);
QueryMemory("Device Current Memory before NotifyComplete ");
NotifyComplete();
}
}