Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void SaveSettings(SettingsType settingsType)
- {
- if (!File.Exists(_settingsFile))
- {
- File.Create(_settingsFile);
- }
- var xmlDoc = XDocument.Load(_settingsFile);
- switch (settingsType)
- {
- case SettingsType.Measurement:
- SaveMeasurementSettings(ref xmlDoc);
- break;
- case SettingsType.Display:
- SaveDisplaySettings(ref xmlDoc);
- break;
- case SettingsType.Common:
- SaveCommonSettings(ref xmlDoc);
- break;
- case SettingsType.View:
- SaveViewSettings(ref xmlDoc);
- break;
- case SettingsType.InputChannel:
- SaveInputChannelSettings(ref xmlDoc);
- break;
- default:
- break;
- }
- xmlDoc.Save(_settingsFile);
- }
- public void Save(string xmlFilePath)
- {
- Thread thread = new Thread(new ParameterizedThreadStart(SaveSettings));
- thread.Start(xmlFilePath);
- }
- private void SaveSettings(object data)
- {
- string xmlFilePath;
- if ((xmlFilePath = data as string) != null)
- {
- this.SaveSettingsFile(xmlFilePath);
- }
- }
- private void SaveSettingsFile(string xmlFilePath)
- {
- // Save the file contents
- }
- public class SettingsType {}
- public class Settings
- {
- private Thread _worker;
- public void SaveSettings(SettingsType type)
- {
- // save logic
- }
- public void BeginSaveSettings(SettingsType type)
- {
- _worker = new Thread(() => SaveSettings(type)) {IsBackground = true};
- _worker.Start();
- }
- public bool EndSaveSettings(TimeSpan timeOut)
- {
- return _worker.Join(timeOut);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement