Thanks a lot. It is working fine now. I used this code on windows and was
trying to search something like it on mono as well.
----------------------------------------------
void ToolStripMenuItemAutoSaveClick(object sender, EventArgs e)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)sender;
            if(item.Checked == true)
            {
            timer = new Timer();
            timer.Interval = 6000;
            timer.Start();
            timer.Tick += AutoSaveEventHandler;
            }
            else
            {
                timer.Stop();
            }
        }
        //auto save event handler
        void AutoSaveEventHandler(object sender, EventArgs e)
        {
            if(Form1.textFilePath != null)
            {
                if(pattern.IsMatch(textFilePath) == true)
                {
                    string f = File.ReadAllText(textFilePath);
                    string pathg = textFilePath + "~";
                    File.WriteAllText(pathg, f);
                    urduRichTextBox1.SaveFile(textFilePath,
RichTextBoxStreamType.RichText);
                }
                else{
                    string f = File.ReadAllText(textFilePath);
                    string pathg = textFilePath + "~";
                    File.WriteAllText(pathg, f);
                urduRichTextBox1.SaveFile(textFilePath,
RichTextBoxStreamType.UnicodePlainText);
                }
            }
----------------------------------------------------
You can see there is no separate thread involved here, System.Timers.Timer
class is working fine. I tried to use this class but the event Timer.Tick
wasn't available and when I tried to use Timer.Elapsed event.
-----------------------------------------------------
if(Action4.Active == true)
            {

            if(textFilePath == null)
            {
                OnSaveActionActivated(sender, e);
            }
            timer = new Timer();
            timer.Interval = 300;
            timer.Start();
            timer.Elapsed += AutoSaveEventHandler;
            }
            else
            {
                timer.Stop();
            }
------------------------------------------
It was pretty much straight forward but I couldn't get it work on mono, it
also frozen the GUI. Can you tell me whats wrong with this code?
Regards

-- 
Muhammad Shakir Aziz محمد شاکر عزیز
_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Reply via email to