Folgendes Problem habe cih derzeit. Ich greife auf eine aktuelle Firebird-DB aus c# heraus mittels des aktuellen .net Providers zu.
Von der DB habe ich zwei Events abonniert. Wenn die Anwendung l+uft funktioniert alles mehrere Stunden lang, dann plötzlich funktioniert der Event-Mechanismus nicht mehr.
Jetzt suche ich nach der Ursache, oder alternativ nach einem Workaround. Falls jemand schon das gleiche Problem hatte, wäre ich für einen Tipp dankbar.
Hier die Klasse welche ich zum Abrufen der DB-Events erstellt habe:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FirebirdSql.Data.FirebirdClient;
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66:
| public class DBEvents : IDisposable { public event EventHandler ResultInserted; protected virtual void OnResultInserted() { EventHandler resultInserted = this.ResultInserted; if (resultInserted != null) resultInserted(this, EventArgs.Empty); }
public event EventHandler MessageInserted; protected virtual void OnMessageInserted() { EventHandler messageInserted = this.MessageInserted; if (messageInserted != null) messageInserted(this, EventArgs.Empty); }
private bool disposed; private FbConnection con = new FbConnection(Properties.Settings.Default.ConnectionString);
public string Initialize() { string result = String.Empty;
try { this.con.Open();
FbRemoteEvent remoteEventMessageInserted = new FbRemoteEvent(con, new string[] { "MESSAGE_INSERTED" }); remoteEventMessageInserted.RemoteEventCounts += (sender, e) => this.OnMessageInserted(); remoteEventMessageInserted.QueueEvents();
FbRemoteEvent remoteEventResultInserted = new FbRemoteEvent(con, new string[] { "RESULT_INSERTED" }); remoteEventResultInserted.RemoteEventCounts += (sender, e) => this.OnResultInserted(); remoteEventResultInserted.QueueEvents(); } catch (FbException e) { result = e.Message; }
return result; }
public void Dispose() { this.Dispose(true); GC.SuppressFinalize(this); }
protected virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { this.con.Close(); this.con.Dispose(); this.con = null; } } this.disposed = true; } } |
Und hier der Konstruktor der GUI-Klasse welche die Events verarbeitet:
C#-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9:
| public PageSupervisor(Message message) { this.Language = XmlLanguage.GetLanguage(System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag); InitializeComponent();
this.dbEvents.Initialize(); this.dbEvents.ResultInserted += (sender, e) => this.resultsInserted();
} |