• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 756
  • Last Modified:

How to run a thread when using .ShowDialog in CF

Hi,
I have a Compact Framework 3.5 application and I need to log to a webservice even if the user has a another form open with .ShowDialog
Is there a way to make a new thread running every 5 minutes?

Rgds
Cynkan
0
cynkan
Asked:
cynkan
  • 7
  • 5
1 Solution
 
daveamourCommented:
Are there any Timers in CF?
0
 
cynkanAuthor Commented:
Yes, there are timers in CF.
0
 
daveamourCommented:
So would one of them not do the trick?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
cynkanAuthor Commented:
No becourse the user has a .ShowDialog form open the mainforms timer would not tick. Thats why I was thinking of making a separate thread for this timer.
0
 
daveamourCommented:
Ok I see well if that is definatley the case then yes just use a different thread.
Le me see if I canknock something together...
0
 
cynkanAuthor Commented:
Thanks, that would be great. I tried to understand how to make a different thread for a timer thats not affect the frozen mainform when using .showdialog.
0
 
daveamourCommented:
I've just tried this with a timer and a ShowDialog and it worked - this was on Winforms though and not CF.  Have you tried this yourself to check that it doesn't tick when the form is shown as ShowDialog?
0
 
cynkanAuthor Commented:
Yes, it works fine in WinForms but not in CF 3.5.
0
 
daveamourCommented:
Ok so to tinker with this I will create a SmartDevice app in Visual Studio 2008.
Give me a few mins...
 
0
 
daveamourCommented:
Ok I'vbe knocked a project together targetting 3.5 and of course I had to try it with a timer and it worked fine.  See attached code.
Am I missing something?

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace EESmartDeviceProject
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
 
            Timer timer = new Timer();
 
            timer.Interval = 2000;
 
            timer.Tick += new EventHandler(timer_Tick);
 
            timer.Enabled = true;
 
            Form2 form = new Form2();
 
            form.ShowDialog();
        }
 
        private void timer_Tick(object sender, EventArgs e)
        {
            MessageBox.Show("Tick");
        }
    }
}

Open in new window

0
 
cynkanAuthor Commented:
Hmm, its something in my project that make this not to work. I tested with a new project and it does work. I have to error trap and see whats happening.
Many thanks for your excellent assistance!
0
 
daveamourCommented:
Your welcome and thanks for the points.
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now