Strange issue with 10.1.1
When downloading data using code which worked just fine in 10, the MobileCache is left in a valid state, but if one clicks the ViewMapTask ArcGIS Mobile crashes (no log file, etc). If you open Mobile again and open the map everything works fantastically well.
Only ever happens after a download (and it is consistent) Code is blow, any thoughts would be greatly appreciated
private void btnGetData_Click_1(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
QueryFilter qf = MakeCacheQuery();
IEnumerable<MobileCacheMapLayerInfo> emi = MobileApplication.Current.Project.EnumerateMobileCacheMapLayerInfos();
foreach (MobileCacheMapLayerInfo mi in emi)
{
MobileCache mc = new MobileCache(mi.MobileCache.StoragePath);
if (mc.CacheExists && mc.IsOpen)
mc.Close();
try
{
var con = new MobileServiceConnection();
con.Url = mi.MobileServiceConnection.Url;
con.CreateCache(mc);
mc.Open();
ICollection<FeatureSource> fSources = mc.FeatureSources;
foreach (FeatureSource fs in fSources)
{
try
{
fSyncAgent = new FeatureSyncAgent(fs, con);
fSyncAgent.SynchronizationDirection = SyncDirection.DownloadOnly;
fSyncAgent.DownloadFilter = qf;
//fSyncAgent.StateChanged += new EventHandler(fSyncAgent_StateChanged);
SyncResults sr = fSyncAgent.Synchronize();
//if (sr.DataSizeReceived == 0)
//{
// System.Threading.Thread.Sleep(500);
// fSyncAgent.Synchronize();
//}
//Application.DoEvents();
}
finally
{
//fSyncAgent.StateChanged -= new EventHandler(fSyncAgent_StateChanged);
fSyncAgent = null;
}
}
}
finally
{
if (mc != null && mc.CacheExists && mc.IsOpen)
{
mc.Close();
//mc.Open();
}
}
}
Cursor.Current = Cursors.Default;
MobileApplication.Current.Transition(MobileApplication.Current.Project.SelectTaskPage);
}