Hello,
VS 2005 Windows Mobile 6.0
I have an application that get data from a web service. This gets done in the main UI thread, as the application cannot move on until this is finished.
However, once the data has been loaded into the dataset, I want to save the contents of the tables in XML on the PDA device itself. It is this that I want to run in the background, so that this form will hide and open another form when this is being done in the background.
Many thanks for any suggestions,
Steve
This is will run in the background in saving the data to xml - THIS IS THE IMPORTANT PART AND SHOULD STILL WORK IF THE NEW FORM HAS BEEN OPENED
Code Block
//This is one example of loading the data into the xml file - there are 5 but I have just added on here to save space on the post..
VS 2005 Windows Mobile 6.0
I have an application that get data from a web service. This gets done in the main UI thread, as the application cannot move on until this is finished.
However, once the data has been loaded into the dataset, I want to save the contents of the tables in XML on the PDA device itself. It is this that I want to run in the background, so that this form will hide and open another form when this is being done in the background.
Many thanks for any suggestions,
Steve
Code:
{
//Load all data into the dataset from the web service
this.LoadDataIntoDataSet();
//Create new background thread
this.workerThreadSaveXML = new Thread(BackgroundProcessSaveXML);
this.workerThreadSaveXML.IsBackground = true;
this.workerThreadSaveXML.Start();
//THIS SHOULD OPEN THE NEW FORM WHILE THE DATA IS STILL BEING SAVED.
frmOrders objOrders = new frmOrders(DS);
objOrders.Show();
this.Hide();
}
Code:
//Load all data into the dataset - NOT RUN IN THE THREAD. THIS HAS TO BE DONE BEFORE THE //NEW FORM WILL OPEN.
private void LoadDataIntoDataSet()
{
try
{
DS = ws.GetStarters();
DS = ws.GetOrders(staffID);
DS = ws.GetBeverages();
DS = ws.GetMainCourses();
DS = ws.GetOrderDetails();
DS = ws.GetMenus();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
This is will run in the background in saving the data to xml - THIS IS THE IMPORTANT PART AND SHOULD STILL WORK IF THE NEW FORM HAS BEEN OPENED
Code Block
Code:
//Save to xml files so that these can be used offline.
private void BackgroundProcessSaveXML()
{
try
{
this.LoadStartersData();
this.LoadBeverageData();
this.LoadOrdersData(staffID);
this.LoadMenus();
this.LoadMaincourse();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
//This is one example of loading the data into the xml file - there are 5 but I have just added on here to save space on the post..
Code:
//Load Starters data
private void LoadStartersData()
{
try
{
//DS = ws.GetStarters();
writeXML.WriteStartersXML(DS);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}