Hi I got the following stack trace from one of my windows phone 8 applications which was called from the background agent called ScheduledTaskAgent1 while call a routine UpdateUI() from what I can gather:
Frame    Image                                  
Function                                                                                                                  
Offset        
0        Microsoft.Phone.Data.Internal.ni.dll   
System.Data.SqlServerCe.SqlCeConnection.Open                                                                              
0x00000534    
1        Microsoft.Phone.Data.Internal.ni.dll   
System.Data.SqlServerCe.SqlCeConnection.Open                                                                              
0x00000006    
2        System.Data.Linq.ni.dll                
System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection                                                             
0x0000008c    
3        System.Data.Linq.ni.dll                
System.Data.Linq.SqlClient.SqlProvider.Execute                                                                            
0x00000038    
4        System.Data.Linq.ni.dll                
System.Data.Linq.SqlClient.SqlProvider.ExecuteAll                                                                         
0x00000080    
5        System.Data.Linq.ni.dll                
System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute                                        
0x0000026c    
6        System.Data.Linq.ni.dll                
System.Data.Linq.DataQuery_1[[System.__Canon,_mscorlib]].System.Linq.IQueryProvider.Execute[[System.__Canon,_mscorlib]]   
0x00000040    
7        System.Core.ni.dll                     
System.Linq.Queryable.FirstOrDefault[[System.__Canon,_mscorlib]]                                                          
0x00000106    
8        ScheduledTaskAgent1.ni.DLL             
ScheduledTaskAgent1.ScheduledAgent.UpdateUI                                                                               
0x0000020a    
9        ScheduledTaskAgent1.ni.DLL             
ScheduledTaskAgent1.ScheduledAgent.OnInvoke                                                                               
0x00000078    
10       Microsoft.Phone.ni.dll                 
Microsoft.Phone.Scheduler.ScheduledTaskAgent.Invoke                                                                       
0x00000432    
11       Microsoft.Phone.ni.dll                 
Microsoft.Phone.BackgroundAgentDispatcher+AgentRequest.Invoke                                                             
0x00000344    
12       Microsoft.Phone.ni.dll                 
Microsoft.Phone.BackgroundAgentDispatcher.InvocationThread                                                                
0x00000080    
13       mscorlib.ni.dll                        
System.Threading.ThreadHelper.ThreadStart_Context                                                                         
0x0000008a    
14       mscorlib.ni.dll                        
System.Threading.ExecutionContext.RunInternal                                                                             
0x00000088    
15       mscorlib.ni.dll                        
System.Threading.ExecutionContext.Run                                                                                     
0x00000010    
16       mscorlib.ni.dll                        
System.Threading.ExecutionContext.Run                                                                                     
0x00000042    
17       mscorlib.ni.dll                        
System.Threading.ThreadHelper.ThreadStart                                                                                 
0x00000042
I am trying to understand what this means and the routine for UpdateUI() is as follows:
private void UpdateUI() { // all variables I have commented out // Get the database context using (db context = new db(ConnectionString)) { try { strTest = (from c in context.Setting where c.Code == "TEST" select c.Value).FirstOrDefault(); } catch (Exception) { // Do nothing for now } } // Get database context using (db context = new db(ConnectionString)) { try { My_template dbMy_template = new My_template(); dbMy_template.myDate = System.DateTime.Now.ToString(); dbMy_template.myValue= myInt.ToString(); context.My_template.InsertOnSubmit(dbMy_template); context.SubmitChanges(); } catch (Exception ex) { // Do nothing for now } } }Thank you for all your help on this. Any ideas or sample on how to do this would be great.