[tasque/transition: 167/213] [libtasque] Make backend IDisposable
- From: Antonius Riha <antoniusri src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tasque/transition: 167/213] [libtasque] Make backend IDisposable
- Date: Wed, 29 Aug 2012 18:48:04 +0000 (UTC)
commit 80acc75ac6e1e1638b4f7c96d630c77cc551122a
Author: Antonius Riha <antoniusriha gmail com>
Date: Sat Aug 18 22:11:59 2012 +0200
[libtasque] Make backend IDisposable
It actually is already IDisposable, but using its own method (Cleanup).
Changed it to Dispose pattern.
Adjustments have been made where necessary.
src/libtasque/Application.cs | 8 ++++----
src/libtasque/Backend.cs | 22 ++++++++++++++++------
2 files changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/src/libtasque/Application.cs b/src/libtasque/Application.cs
index 7adb421..8b1d406 100644
--- a/src/libtasque/Application.cs
+++ b/src/libtasque/Application.cs
@@ -99,7 +99,7 @@ namespace Tasque
// Cleanup the old backend
try {
Debug.WriteLine ("Cleaning up backend: {0}", backend.Name);
- backend.Cleanup ();
+ backend.Dispose ();
} catch (Exception e) {
Trace.TraceWarning ("Exception cleaning up '{0}': {1}", backend.Name, e);
}
@@ -197,7 +197,7 @@ namespace Tasque
OnQuitting ();
if (backend != null)
- backend.Cleanup ();
+ backend.Dispose ();
QuitMainLoop ();
}
@@ -237,11 +237,11 @@ namespace Tasque
#endregion
#region Backend loading and helpers
- protected void RetryBackend()
+ protected void RetryBackend ()
{
try {
if (backend != null && !backend.Configured) {
- backend.Cleanup();
+ backend.Dispose();
backend.Initialize();
}
} catch (Exception e) {
diff --git a/src/libtasque/Backend.cs b/src/libtasque/Backend.cs
index 8ee5e42..0b4816b 100644
--- a/src/libtasque/Backend.cs
+++ b/src/libtasque/Backend.cs
@@ -35,7 +35,7 @@ namespace Tasque
/// This is the main integration interface for different backends that
/// Tasque can use.
/// </summary>
- public abstract class Backend
+ public abstract class Backend : IDisposable
{
protected Backend (string name)
{
@@ -116,14 +116,24 @@ namespace Tasque
/// </value>
public ReadOnlySortedNotifyCollection<Task> Tasks { get; private set; }
#endregion
+
+ #region IDisposable implementation
+ public void Dispose ()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing) {}
+
+ ~Backend ()
+ {
+ Dispose (false);
+ }
+ #endregion
#region Methods
/// <summary>
- /// Cleanup the backend before quitting
- /// </summary>
- public abstract void Cleanup ();
-
- /// <summary>
/// Create a new task.
/// </summary>
public Task CreateTask (string taskName, Category category)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]