473,394 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

vb.net: CAN, timers, while loops, and Application.DoEvents()

I'm new to vb.net and i'm building code in vb.net that inputs and outputs CAN-messages in visual studio 2003 with an IFAK CAN driver. I want to make a loop that checks the results of a global variable incremented/changed by the timer. I enable a timer with the following code
Expand|Select|Wrap|Line Numbers
  1.         timerCounter = 0
  2.         timer.Interval = 30
  3.         timer.Enabled = True
  4.  
the windows autocode only generates:
Expand|Select|Wrap|Line Numbers
  1. Me.timer = New System.Windows.Forms.Timer(Me.components)
  2.  
in the timer_tick event i increment timerCounter-integer and read a value into messageRead-arraylist from ReadMessage sub
Expand|Select|Wrap|Line Numbers
  1.         messageInfo = ReadMessage(15)
  2.         timerCounter += 1
  3.         messageRead.Add(messageInfo)
  4.  
i loop and check timerCounter with the following command:
Expand|Select|Wrap|Line Numbers
  1. System.Windows.Forms.Application.DoEvents()
  2.  
before i put this in code in the program looped infinitely, i think that this line forces the program to go to any available event.

My problem is that if the device is connected by the routine, the program crashes, but if it is connected before the program still runs. The device needs to be connected in the routine

What can i do? Is there another method like Refresh()? Should i look into multi-threading?
Oct 10 '07 #1
2 2522
r035198x
13,262 8TB
Moved to .NET forum
Oct 11 '07 #2
pbmods
5,821 Expert 4TB
Heya, Taylor. Welcome to TSDN!

Please use CODE tags when posting source code:

[CODE=vb]
Visual Basic code goes here.
[/CODE]
Oct 11 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: jean | last post by:
I am very new to .Net and Visual Basic in general. My goal is to write a Visual Basic .Net DLL that can have its functions and subroutines called from another .Net application. My DLL will not...
3
by: Jeff Greenland | last post by:
Hello everyone, I am having problems with Timers in a web application. They just seem to stop running after 15 minutes or so. My web application is set up like this: When a user hits a...
12
by: Jack Russell | last post by:
My unstanding of all VB up to and including vb6 is that an event could not "interrupt" itself. For instance if you had a timer event containing a msgbox then you would only get one message. ...
1
by: Viet | last post by:
I don't know if this is the right forum for my question but here goes: I am converting a VB6 app to VB.NET and I would like to use Threads and Threadpools. This main app (1) executes two other sub...
7
by: oop_dude | last post by:
I'm trying to use a thread in the following situation, but having never used threading before, I don't know where to begin. My program has a timer set to fire every 10 seconds or so. In the tick...
6
by: ransoma22 | last post by:
I developing an application that receive SMS from a connected GSM handphone, e.g Siemens M55, Nokia 6230,etc through the data cable. The application(VB.NET) will receive the SMS automatically,...
8
by: Luc | last post by:
Hi, I am writing software to automate some testing. I have one main form to set up the tests, and once this is complete, I open 4 identical forms to monitor each different device that I am...
5
by: FredC | last post by:
I have an application that uses mulitple timers. Each of the timer event handlers manipulate a common array of data. I'm getting Null refererance errors - should I put a lock on the array when I...
12
by: =?Utf-8?B?TWlrZVM=?= | last post by:
Can someone tell me why my program hangs when I call a timer function from within a Do Loop. Here is the code: Public Class MainForm Public intCounter As Double = 0 Public intMin As Double...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.