Implementing double click event using timer - c#

As I mentioned in this question, I am trying to implement a feature in my app whereby placing a cursor over some point for a while (say 3-5 seconds) triggers a double-click event. Based on the answers provided in that thread, I wrote the following. This code is not working as expected. Can someone please help?
#region Timer Mouse Double Click event
timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
//Here, the timer for Timer click event will start when mouse hovers over an area
private void form_MouseHover(object sender, System.EventArgs e)
{
timer.Start();
}
private void form_MouseLeave(object sender, System.EventArgs e)
{
timer.Stop();
}
void timer_Elapsed(object sender, ElapsedEventArgs e)
{
timer.Stop();
DoubleClickEvent();
}
//This method allows the user to click a file/folder by hovering/keeping still the mouse for specified time
void DoubleClickEvent()
{
DoClickMouse(0x2); // Left mouse button down
DoClickMouse(0x4); // Left mouse button up
}
static void DoClickMouse(int mouseButton)
{
var input = new INPUT()
{
dwType = 0, // Mouse input
mi = new MOUSEINPUT() { dwFlags = mouseButton }
};
if (SendInput(1, input, Marshal.SizeOf(input)) == 0)
{
throw new Exception();
}
}
[StructLayout(LayoutKind.Sequential)]
struct MOUSEINPUT
{
int dx;
int dy;
int mouseData;
public int dwFlags;
int time;
IntPtr dwExtraInfo;
}
struct INPUT
{
public uint dwType;
public MOUSEINPUT mi;
}
[DllImport("user32.dll", SetLastError = true)]
static extern uint SendInput(uint cInputs, INPUT input, int size);
#endregion

At first glance if your expecting a double click your are only doing a single click.
Down then up is one mouse click, shouldn't you do.
void DoubleClickEvent()
{
DoClickMouse(0x2); // Left mouse button down
DoClickMouse(0x4); // Left mouse button up
DoClickMouse(0x2); // Left mouse button down
DoClickMouse(0x4); // Left mouse button up
}

I hope it's not bad etiquette to provide two answers, however this is very different from my previous answer I felt editing for improvements wasn't correct.
By the looks of it you only have an event handler on the form, once you hover over a control on your form that will trigger your MouseLeave event of the form.
What you need is to add an event handler to every control on your form, something like this should do it.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.MouseHover += new EventHandler(MouseHoverEvent);
this.MouseLeave +=new EventHandler(MouseLeaveEvent);
timer1.Tick += new EventHandler(timer1_Tick);
foreach (Control item in this.Controls)
{
item.MouseHover += new EventHandler(MouseHoverEvent);
item.MouseLeave += new EventHandler(MouseLeaveEvent);
}
}
void timer1_Tick(object sender, EventArgs e)
{
timer1.Stop();
DoubleClickEvent();
}
void MouseLeaveEvent(object sender, EventArgs e)
{
timer1.Stop();
}
void MouseHoverEvent(object sender, EventArgs e)
{
timer1.Start();
}
}

It might be better to write this code as a single call to SendInput passing all the mouse downs and ups in one array. If you do this, SendInput guarantees that no other keys get in between the sequence. For example if a user has Alt + N keys held in theory it could sneak in - and change the auto-clicker clicking Yes to instead trigger a No (with a Alt + N keys held).
That being said however, I think the answer to our question is here: SendInput doesn't perform click mouse button unless I move cursor

Basic Idea:
I use MouseAdapter so that I don't have to override everything under the sun.
my MouseAdapter object has a MouseTimer which extends a swing Timer,
and an ActionListener with an overridden anonymous actionPerformed method.
I may have over thought/ or under thought when to start and stop the timer object.
Basically all it does is print out when it is single clicked or when it is double clicked.
package mouseUtils;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.Timer;
/**
*
* #author jcpartri
*/
public class MyMouseAdapter extends MouseAdapter{
private Integer mouseDoubleClickInterval = (int)
Toolkit.getDefaultToolkit().getDesktopProperty("awt.multiClickInterval");
private MouseEvent event = null;
private ActionListener taskPerformer = new ActionListener(){
#Override
public void actionPerformed(ActionEvent e){
if(event.getClickCount() == 2){
//mouseDoubleClicked(event);
mouseTimer.stop();
}
if(event.getClickCount() == 1){
//mouseSingleClicked(event);
mouseTimer.stop();
}
}
};
Class MouseTimer is a child of class Timer. When the Timer fires after a delay, there is a check to see if there was a single or double click within that timespan.
private MouseTimer mouseTimer = new
MouseTimer(getMouseDoubleClickInterval(),taskPerformer);
//The DebugClock helps me to see how long a process that I have programmed takes from
start to finish.
private DebugClock clock = new DebugClock();
//Constructors
public MyMouseAdapter(){
super();
}
#Override
public void mouseClicked(MouseEvent e){
event = e;
if(e.getClickCount() == 1){
mouseTimer.setInitialDelay(mouseDoubleClickInterval);
mouseTimer.start();
}
mouseTimer.setNumOfClicks();
}
public void mouseSingleClicked(MouseEvent e){
p("Mouse was SingleClicked!!!\n");
}
public void mouseDoubleClicked(MouseEvent e){
p("Mouse was DoubleClicked!!!\n");
}
#Override
public void mouseMoved(MouseEvent e){
event = e;
mouseTimer.resetNumOfClicks();
mouseTimer.stop();
}
//Setters and Getters for MouseAdapter
public Integer getMouseDoubleClickInterval(){
return this.mouseDoubleClickInterval;
}
//Timer Classes
private class MouseTimer extends Timer{
//Constructors
public MouseTimer(int delay, ActionListener taskPerformer){
super(delay,taskPerformer);
}
//Instance variables
private int numOfClicks = 0;
//Setters and Getters
public int getNumOfClicks(){
return this.numOfClicks;
}
public void setNumOfClicks(){
this.numOfClicks++;
}
public void resetNumOfClicks(){
this.numOfClicks = 0;
}
}
//Basic Printing Classes
private void p(String message){
System.out.print(message);
}
}
class DebugClock{
private long startTime = 0;
private long endTime = 0;
//Setters and Getters
public long getStartTime(){
return this.startTime;
}
public void setStartTime(long start){
this.startTime = start;
}
public long getEndTime(){
return this.endTime;
}
public void setEndTime(long end){
this.endTime = end;
}
//Constructors
public DebugClock(){
}
//Methods
public float getTimeInMilliSeconds(){
float seconds = (this.endTime - this.startTime);
return seconds;
}
}

Related

How to make popup form when enter and leave object? C#

I am working on fitness project and need to creat a form with gif over text, when mouse is pointed on it and close popup when mouse leave it. In my case it works only one time. When pointing second time it returnes System.ObjectDisposedException "Access to the liquidated object is not possible"
Here is a code with text
namespace WindowsFormsApp1
{
public partial class Power : Form
{
public Power()
{
InitializeComponent();
}
public PopupDemo PopupDemo = null;
private void guna2CheckBox1_MouseHover(object sender, EventArgs e)
{
StartPopupDemo();
}
private void guna2CheckBox1_MouseLeave(object sender, EventArgs e)
{
PopupDemo.Close();
}
private void StartPopupDemo()
{
int MouseX = Cursor.Position.X;
int MouseY = Cursor.Position.Y;
PopupDemo = new PopupDemo();
PopupDemo.Show();
PopupDemo.Location = new Point(MouseX - PopupDemo.Width / 2, MouseY - PopupDemo.Height - 10);
}
}
}
Also i used nuget packages named Guna.
And ther is popup code
namespace WindowsFormsApp1
{
public partial class PopupDemo : Form
{
public PopupDemo()
{
InitializeComponent();
}
}
}
I hope there is more appropriate command instead of Close().
Help pls. If needed something else, just tell me. This is how it looks like

How to check if user is idle on UWP? [duplicate]

This question already has answers here:
Detect if user Idle on windows universal app
(2 answers)
Closed 6 years ago.
I wanted to make a function that would timeout and navigate to the main page if the user is idle for a certain period of time. After a little research, I found that the ThreadPoolTimer should suit my needs. Testing it I decided to use a 10 sec interval.
timer =ThreadPoolTimer.CreatePeriodicTimer(Timer_Tick,TimeSpan.FromSeconds(10));
And this is where I'm at a loss. I couldn't figure out a way to check user input on a UWP without having to individually check PointerPressed, PointerExited, etc. So I did some more digging and I found a block of code that's supposed to give you a boolean value if the user is idle or not.
public static uint GetIdleTime()
{
LASTINPUTINFO lastInPut = new LASTINPUTINFO();
lastInPut.cbSize = (uint)Marshal.SizeOf(lastInPut);
GetLastInputInfo(ref lastInPut);
return ((uint)Environment.TickCount - lastInPut.dwTime);
}
public static bool IsUserIdle()
{
uint idleTime = (uint)Environment.TickCount - GetLastInputEventTickCount();
if (idleTime > 0)
{
idleTime = (idleTime / 1000);
}
else
{
idleTime = 0;
}
//user is idle for 10 sec
bool b = (idleTime >= 10);
return b;
}
private static uint GetLastInputEventTickCount()
{
LASTINPUTINFO lii = new LASTINPUTINFO();
lii.cbSize = (uint)Marshal.SizeOf(lii);
lii.dwTime = 0;
uint p = GetLastInputInfo(ref lii) ? lii.dwTime : 0;
return p;
}
[StructLayout(LayoutKind.Sequential)]
private struct LASTINPUTINFO
{
public static readonly int SizeOf = Marshal.SizeOf<LASTINPUTINFO>();
[MarshalAs(UnmanagedType.U4)]
public UInt32 cbSize;
[MarshalAs(UnmanagedType.U4)]
public UInt32 dwTime;
}
[DllImport("user32.dll")]
private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
I then call the function in the tick function and use the conditional statement if IsUserIdle() is equal to true then navigate to the main page.
public static void Timer_Tick(object sender)
{
if (IsUserIdle() == true)
{
Frame.Navigate(typeof(MainPage));
}
}
But when I start it nothing happens, and after I set a couple breakpoints I found that IsUserIdle() never returns a true value even after 10 sec of inactivity. I am completely stuck so any help would be appreciated.
GetLastInputInfo isn't supported for Windows store apps:
Minimum supported client: Windows 2000 Professional [desktop apps only]
I'm not aware of any intrinsic UWP API to detect if the user is idle, but it's definitely possible to whip up your own mechanism for doing so.
I couldn't figure out a way to check user input on a UWP without having to individually check PointerPressed, PointerExited, etc.
What's so bad about that approach? Here's my attempt:
App.xaml.cs
public sealed partial class App : Application
{
public static new App Current => (App)Application.Current;
public event EventHandler IsIdleChanged;
private DispatcherTimer idleTimer;
private bool isIdle;
public bool IsIdle
{
get
{
return isIdle;
}
private set
{
if (isIdle != value)
{
isIdle = value;
IsIdleChanged?.Invoke(this, EventArgs.Empty);
}
}
}
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
idleTimer = new DispatcherTimer();
idleTimer.Interval = TimeSpan.FromSeconds(10); // 10s idle delay
idleTimer.Tick += onIdleTimerTick;
Window.Current.CoreWindow.PointerMoved += onCoreWindowPointerMoved;
}
private void onIdleTimerTick(object sender, object e)
{
idleTimer.Stop();
IsIdle = true;
}
private void onCoreWindowPointerMoved(CoreWindow sender, PointerEventArgs args)
{
idleTimer.Stop();
idleTimer.Start();
IsIdle = false;
}
}
MainPage.xaml.cs
public sealed partial class MainPage : Page
{
protected override void OnNavigatedTo(NavigationEventArgs e)
{
App.Current.IsIdleChanged += onIsIdleChanged;
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
App.Current.IsIdleChanged -= onIsIdleChanged;
}
private void onIsIdleChanged(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine($"IsIdle: {App.Current.IsIdle}");
}
}
Idle is detected when the pointer hasn't moved for 10s within the app window. This will work also for touch-only apps (like mobile apps) because PointerMoved will fire when the window is tapped, too.

Timer sequence is messing up

So I am making a Robbery system the timer works perfectly on the first start but on second try it minuses the time 2ice.. meaning the sequence by the timer goes down is 10,9,8,7...... But on the 2nd try the sequence is 10,8,6,4...... on the 3rd try its 10,7,4,1..... Etc meaning on each start the timer sequence increase the decrease time? How is it possible?
public void robberyCountdown(User player)
{
time = 10;
cd.Elapsed += (source, e) => OnTimer(player);
cd.Start();
}
public void OnTimer(User player)
{
cd.Stop();
cd.Elapsed -= (source, e) => OnTimer(player);
}
Save the delegate you create into a private field so you can access it later:
private ElapsedEventHandler _onTimer;
public void robberyCountdown(User player)
{
time = 10;
_onTimer = (source, e) => OnTimer(player)
cd.Elapsed += _onTimer;
cd.Start();
}
public void OnTimer(User player)
{
cd.Stop();
cd.Elapsed -= _onTimer;
}
Of course, this approach assumes that player will be the same for both. A better way is probably to make your delegate just be constant, and use a private field to keep track of which players are being timed.
private HashSet<Player> _timedPlayers = new HashSet<Player>();
public MyClass() // or whatever your constructor is called
{
cd.Elapsed += OnTimer;
}
public void OnTimer(Object source, ElapsedEventArgs e)
{
foreach(var player in _timedPlayers)
{
// ...
}
}
public void robberyCountdown(User player)
{
time = 10;
_timedPlayers.Add(player);
cd.Start();
}
public void OnTimer(User player)
{
cd.Stop();
_timedPlayers.Remove(player);
}

Redirecting Events to handlers inside custom controls

I have mad a custom control. and i need to redirect the Event handler. i have cut the code down dramatically to try and articulate what im trying to do.
public class RemoteDesktop : WindowsFormsHost
{
public event OnConnectingEventHandler OnConnecting;
public delegate void OnConnectingEventHandler(object sender, EventArgs Arguments);
public event OnDisconnectingEventHandler OnDisconnecting;
public delegate void OnDisconnectingEventHandler(Object sender, IMsTscAxEvents_OnDisconnectedEvent Arguments);
private AxMsRdpClient7NotSafeForScripting RDPUserControl = new AxMsRdpClient7NotSafeForScripting();
public RemoteDesktop()
{
this.RDPUserControl.BeginInit();
this.RDPUserControl.SuspendLayout();
base.Child = RDPUserControl;
this.RDPUserControl.ResumeLayout();
this.RDPUserControl.EndInit();
}
}
public class RemoteDesktopViewModel
{
public RemoteDesktopViewModel()
{
RemoteDesktop newRDC = new RemoteDesktop();
newRDC.OnConnecting += new RemoteDesktop.OnConnectingEventHandler(newRDC_OnConnecting);
}
void newRDC_OnConnecting(object sender, EventArgs Arguments)
{
//DoStuff
}
}
basically it all works, i can connect and disconnect to the remote computer however i cannot get the fired events to occur in my view model.
Can anyone help me figure out how i can point my events correctly.
Thank you.
Thanks to some help i have the resolution
Step 1:
Declare delegates outside the class (within the namespace)
Step 2:
Declare the events to be called for the control.
Step 3: use the event handlers of the controls to reise the delegates you created
Completed Code
public delegate void OnConnectingEventHandler(object sender, EventArgs Arguments);
public delegate void OnDisconnectingEventHandler(Object sender,IMsTscAxEvents_OnDisconnectedEvent Arguments);
public class RemoteDesktop : WindowsFormsHost
{
public event OnConnectingEventHandler IsConnecting;
public event OnDisconnectingEventHandler IsDisconnecting;
private AxMsRdpClient7NotSafeForScripting RDPUserControl = new AxMsRdpClient7NotSafeForScripting();
public RemoteDesktop()
{
this.RDPUserControl.BeginInit();
this.RDPUserControl.SuspendLayout();
base.Child = RDPUserControl;
this.RDPUserControl.ResumeLayout();
this.RDPUserControl.EndInit();
RDPUserControl.OnConnecting += RemoteDesktop_OnConnecting;
RDPUserControl.OnDisconnected += RDPUserControl_OnDisconnected;
}
void RDPUserControl_OnDisconnected(object sender, IMsTscAxEvents_OnDisconnectedEvent e)
{
IsDisconnecting(sender, e);
}
void RemoteDesktop_OnConnecting(object sender, EventArgs Arguments)
{
IsConnecting(sender, Arguments);
}
}
public class RemoteDesktopViewModel
{
public RemoteDesktopViewModel()
{
RemoteDesktop newRDC = new RemoteDesktop();
newRDC.IsConnecting += new RemoteDesktop.OnConnectingEventHandler(newRDC_OnConnecting);
}
void newRDC_OnConnecting(object sender, EventArgs Arguments)
{
//DoStuff
}
}
//at the constractor of the class
OnConnecting+=RDC_OnConnecting;
then you can write your logic in method:newRDC_OnConnecting. make sure OnConnectingEventHandler have same method signatures with newRDC_OnConnecting.

C# Sql Server "loading window"

This is my first post here, but I've using this site regularly to help me with my own app's, and I should say that this site has been a great help to me, so thanks to everyone.
Now my question:
I'm developing my first software app that exchanges data between a sql server and the app itself. It's beeing developed in C#. Saving or retreiving data from the sql server database is no problem.
What I want is a way to inform the user of the delay between the local machine (where the app is installed) and the server. I can make some animations or simply display some text messages. What I need help with is how to create the code that activates/fires/runs when that server communication time is running.
If you can't understand the idea, picture a video game. When it's loading (in some games) you can see the loading screen before the game starts. I need some code that displays that "loading window" when the the app is downloading or uploading data from/to the server.
I would appreciate any code example or web site recommendation.
PS: Sorry for the extensive text, but I want to make sure everyone understand so I don't have to repeat it again :P
How do I implement a progress bar in C#?
How to create a smooth progress bar in Visual C#
ProgressBar Class
I have developed a simple PleaseWait class 2 years ago, but I didn't update this class, It works very well, have look hope this will give you an idea to implement your logic.
public partial class frmWait : Form
{
public frmWait()
{
InitializeComponent();
}
bool _isMoving = false;
int _moveStart_x = 0;
int _moveStart_y = 0;
private void tmrProgress_Tick(object sender, EventArgs e)
{
if (barProgress.Value == barProgress.Maximum)
barProgress.Value = barProgress.Minimum;
else
barProgress.Value += 1;
}
private void btnCancel_Click(object sender, EventArgs e)
{
Close();
PleaseWait.Abort();
}
protected override CreateParams CreateParams
{
get
{
System.Windows.Forms.CreateParams p = base.CreateParams;
p.ClassStyle += 0x20000;
p.ExStyle += 0x8000000;
return p;
}
}
protected override void WndProc(ref Message m)
{
const int WM_NCHITTEST = 132;
base.WndProc(ref m);
switch (m.Msg)
{
case WM_NCHITTEST:
if (m.Result.ToInt32() == 1)
m.Result = new IntPtr(2);
break;
}
}
private void panelEx1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
_isMoving = true;
_moveStart_x = e.X;
_moveStart_y = e.Y;
}
}
private void panelEx1_MouseUp(object sender, MouseEventArgs e)
{
_isMoving = false;
}
private void pnlContainer_MouseMove(object sender, MouseEventArgs e)
{
if (_isMoving)
this.Location = new Point(Location.X + e.X - _moveStart_x, Location.Y + e.Y - _moveStart_y);
}
}
public class PleaseWait
{
#region Static Operations
private static Boolean _isAborted = false;
private static Boolean _isVisible = false;
private static frmWait _waitForm;
private static String _waitingState = "";
private static Boolean _autoClose = false;
private static Boolean _cancelable = false;
private static System.Threading.Thread _waiterThred;
public delegate void CancelButtonPressed();
public static event CancelButtonPressed OnCancel;
public static Boolean AutoClose
{
get { return PleaseWait._autoClose; }
set { PleaseWait._autoClose = value; }
}
public static string WaitingState
{
get { return PleaseWait._waitingState; }
set { PleaseWait._waitingState = value; }
}
public static bool IsVisible
{
get { return _isVisible; }
internal set { _isVisible = value; }
}
public static void ShowPleaseWait()
{
ShowPleaseWait("", _autoClose, false);
}
public static void ShowPleaseWait(string waitingState)
{
ShowPleaseWait(waitingState, _autoClose, false);
}
public static void ShowPleaseWait(bool autoClose)
{
ShowPleaseWait("", autoClose, false);
}
public static void ShowPleaseWait(string waitingState, bool autoClose, bool cancelable)
{
if (_waiterThred != null)
{
if (_isVisible)
{
// the please wait it woking, just continue and apply the changes
_waitingState = waitingState;
_autoClose = autoClose;
_cancelable = cancelable;
return;
}
else
{
_waiterThred.Abort();
_waiterThred = null;
}
}
_waitingState = waitingState;
_autoClose = autoClose;
_cancelable = cancelable;
_isAborted = false;
_isVisible = false;
if (_autoClose)
Application.Idle += new EventHandler(Application_Idle);
_waiterThred = new System.Threading.Thread(DisplayWaitingForm);
_waiterThred.IsBackground = true;
_waiterThred.Name = "Please Wait....";
_waiterThred.Start();
Application.DoEvents();
}
public static void Abort()
{
_isAborted = true;
}
private static void Application_Idle(object sender, EventArgs e)
{
if (_autoClose)
_isAborted = true;
}
private static void DisplayWaitingForm()
{
if (_waitForm != null)
{
if (!_waitForm.IsDisposed)
_waitForm.Dispose();
_waitForm = null;
_isVisible = false;
}
try
{
if (_isAborted)
return;
_waitForm = new frmWait();
if (_cancelable)
{
_waitForm.btnCancel.Enabled = true;
_waitForm.btnCancel.Click += new EventHandler(btnCancel_Click);
}
try
{
_isVisible = true;
_waitForm.Show();
_waitForm.Focus();
while (!_isAborted)
{
System.Threading.Thread.Sleep(15);
_waitForm.lblMessage.Text = _waitingState;
Application.DoEvents();
_waitForm.lblMessage.Text = _waitingState;
}
_isVisible = false;
}
finally
{
FreeWaitingForm();
}
}
finally
{
_isVisible = false;
}
}
static void btnCancel_Click(object sender, EventArgs e)
{
if (_waitForm.InvokeRequired)
{
_waitForm.BeginInvoke(new EventHandler(btnCancel_Click), new object[] { e });
}
else
{
if (OnCancel != null)
OnCancel.Invoke();
}
}
private static void FreeWaitingForm()
{
_waitingState = "";
_isVisible = false;
if (_waitForm == null)
{
return;
}
_waitForm.Hide();
if (!_waitForm.IsDisposed)
_waitForm.Dispose();
_waitForm = null;
}
#endregion
}
use like following code :
PleaseWait.ShowPleaseWait("Please wait", true, false);
// If second param is true then it will close the form automatically.
// If third param is true the it will expose a cancel button, so you can cancel your Asynchronous operations.
I didn't insert design code, you can understand by looking at code.
hope this help.
First let me thank you for your replies.
Toby your answer got me thinking about thread monitoring my sql connections but it was a bit tricky and confusing since the app is still in develop and will use a lot more connections.
S.Amani answer it wasn't quite what I want, but thanks to that I found a easier way. I created a form (could be anything else), placed a label saying: Saving To Data Base, took out the top bar, defined location and defined it's parent to be disabled when shown and enabled when closed. The following code is what I put inside my DataBaseInteractionClass
private Wait myCustomWaitDialog = new Wait(); // My Waiting form
private void SaveToDatabase(myObjectToSave obj) // Method called to save data do DB
{
// Create the connections and queries
(...)
// This is what I did
// Show Waiting Form
myCustomWaitDialog.Show();
// Instanciate the command that will carry the query and to DB
SqlCommand command = new SqlCommand(Queries.GetData(code), conn);
// This is important
//Create event that will fire when the command completes
command.StatementCompleted += new StatementCompletedEventHandler(command_StatementCompleted);
// Execute the transaction
SqlDataReader reader = command.ExecuteReader();
// Rest of the code (validations, close connections, try/catch, etc
(...)
}
void command_StatementCompleted(object sender, StatementCompletedEventArgs e)
{
// This is the method that closes my Waiting Dialog
myCustomWaitDialog.CloseDialog();
myCustomWaitDialog.Dispose();
}
It's not quite what I want yet, but is the best solution that I found so far. For now it will do :)
Anyway, thanks for the replies and I hope this helps someone else.

Categories