LOG IN

Forgot Your Password?


Incorrect login or password

SIGN UP



Existing user?

Forgot Password


Existing user?

Components

Timer in .NET

A timer is one of many components that are non-visible within the runtime of a program. A timer is used to create a sub-like operation that repeats with interval of N milliseconds. The commands within the timer can only run when the timers enabled property is set to true. This can be done by using the following code:

  TimerName.Enabled = True

This code is usually put in a "on click" handler but it can also be used in almost any other handler. To put a timer into your project you must first drag and drop the timer icon from the tool box into your form and then click the timer twice where it is shown under the form to modify the code within it, then you can change the properties accordingly.


Interval

The Interval property is the amount of milliseconds set between each tick this can be changed through the properties panel or be set through the following code

  TimerName.Interval = 1000  'desired integer here

Enabled

The enabled property is the Boolean property in which the status of the timer is set. This can be changed through the properties or through the following code

  Timer

Name.Enabled = True  'or False

Generally, each program in Windows has its own virtual memory space. In other words, one program cannot change variables in another program. Marshalling is the process of passing data and memory addresses between applications. There are several ways different programs can communicate with each other.


Shared file(s)

This is a 'roll your own' solution. Both applications access files in a shared directory, reading and writing data from them to communicate. The simplest method is for the sending application to write a separate file for each message and the receiving application to delete those files once processed. The sending application should create the file with exclusive access so the receiving application cannot access a half-written file. There should also be a mechanism for re-synchronising if one or the other application is shut down during a conversation.

The main downside of this approach is that the receiving application must poll the shared directory at regular intervals (e.g. by using a Timer control). This generates harddisk/network traffic, and the polling interval limits the responsiveness of the conversation.
Windows messages

This method consists of overriding the WndProc method in a Form to receive, and the PostMessage Win32 API call to send a custom Windows message.
.NET Remoting

This method has the advantage of easily accommodating both communication between programs on the same computer, and programs on different computers in the same network (or even across the internet). It uses the System.Runtime.Remoting namespace, which you can add via Project References.
Older methods

These methods are not used much anymore, but may be encountered if you are trying to communicate with a legacy application.
DDE

Dynamic Data Exchange was the original method Windows used for programs to communicate with each other. It is still used by Windows for "Cut and Paste".
OLE

Source: https://en.wikibooks.org/wiki/Visual_Basic_.NET/Interprocess_Communication


 << Previous  Next >>