C#Skype4Com应用程序停止执行它的工作

时间:2016-03-07 13:52:27

标签: c# mysql skype skype4com

我一直在研究一个简单的应用程序来将所有skype消息存储在mysql数据库中,但似乎在几分钟(10-20)后应用程序停止执行它的工作。我的意思是我仍然在Skype中接收消息,应用程序仍在运行(没有崩溃),但它不会将它们发送到数据库。我尝试了不同的附件ID,但它仍然是相同的。

using SKYPE4COMLib;
using MySql.Data.MySqlClient;

    public partial class SkypeAgent : Form
{
    public SkypeAgent()
    {
        InitializeComponent();
        ShowInTaskbar = false;
        this.WindowState = FormWindowState.Minimized;
        var skype = new Skype();
        skype.Attach(7, false);
        skype.MessageStatus += new _ISkypeEvents_MessageStatusEventHandler(skype_MessageStatus);
    }
    private void skype_MessageStatus(ChatMessage msg, TChatMessageStatus status)
    {
        MySqlConnection con = new MySqlConnection(@"server=localhost;database=text;userid=root;password=ascent");
        string message = msg.Sender.FullName + ": " + msg.Body;
        MySqlCommand comm = con.CreateCommand();
        comm.CommandText = "INSERT INTO texts (text, id) VALUES ('" + message + "', '1')";
        con.Open();
        comm.ExecuteNonQuery();
        con.Close();
    }
}

0 个答案:

没有答案