473,396 Members | 1,792 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,396 software developers and data experts.

ThreadPool use causes Application Error

I have a simple program to read data from a touchscreen overEthernet using a custom DLL provided by the touchscreenmanufacturer, and I want to read this data using the threadpool.When I use the threadpool to complete the task(StartThreadButton_Click), I encounter the following errormessage when I close my application.

.NET-BroadcastEventWindow.1.0.5000.0.3: WindowsApplication1.exe -Application Error
The instruction at "0x6c3b5115" referenced memory at"0x00000004". The memory could not be "read".
Click on OK to terminate the program

When I run the sub-routine without using the threadpool(StartNormalButton_Click), I do not encounter this error messagewhen I close my application.

Is anyone familiar with this type of error, and can anyone make asuggestion?

The outline of my code is included below.

Regards,
Ryan
Public Class Form1
Inherits System.Windows.Forms.Form

Friend Class RefreshDataArgsConstruct
Public parent As Form1
End Class

' Declare the ThreadPool
Dim myThreadPool As ThreadPool

Private Sub StartThreadButton_Click(ByVal sender As Object,ByVal e As EventArgs) Handles StartThreadButton.Click

Dim dataArgs As New RefreshDataArgsConstruct
dataArgs.parent = Me
myThreadPool.QueueUserWorkItem(New WaitCallback(AddressOfRefreshData), dataArgs)

End Sub

Private Sub StartNormalButton_Click(ByVal sender As Object,ByVal e As EventArgs) Handles StartNormalButton.Click

Dim dataArgs As New RefreshDataArgsConstruct
dataArgs.parent = Me
RefreshData(dataArgs)

End Sub

Public Sub RefreshData(ByVal dataArgs As Object)

Dim myParent As Form1 = CType(dataArgs.parent, Form1)
Dim data As CtrlStnData =ReadData(myParent.IpAddress.Text)
myParent.DataSample.Text = "Success: " &data.success.ToString

End Sub

' Reading the data from the touchscreen
Private Function ReadData(ByVal ip As String) As CtrlStnData

' Create a return variable
Dim data As CtrlStnData

' Lock the communication semaphore
SyncLock doFunc

' Read data from the touchscreen (DLL calls)
err = HKEtn_Init(10000, 2, 2, 2)
HKEtn_Close()

End SyncLock

' 0 = Error Occurred in Ethernet Comms
If err = 0 Then
data.success = False : Return data
Else
data.success = True : Return data
End If

End Function

End Class

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>KI8wXJaaZUu6Ki3xWKcJWg==</Id>
Nov 21 '05 #1
0 1020

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dan Battagin | last post by:
Is there a known bug with the interaction between the HttpWebRequest and the ThreadPool? I current spawn several HttpWebRequest's using BeginGetResponse, and they work for a while, using worker...
4
by: David Levine | last post by:
Jon, I've taken a look at it and these comments are based on a code-inspection but I did not verify the correctness if its operation by using it in a sample. The ctor for CustomThreadPool...
5
by: Duane Pressley | last post by:
I'm looking for someone to help me make sense of the results I'm observing when using the ThreadPool class in a COM-Interop scenario. Here's the set up: 1.. A classic ASP page instantiates and calls...
11
by: AA | last post by:
Why microsoft make so hard to change the max Pool Size?? I really need to change it to 50, because I'm using delegates with BeginInvoke and I saw that they (delegates) use the ThreadPool, but I...
6
by: Serge | last post by:
hi, the framework has the ThreadPool class. Very handy. But as far as I can see this is a singleton (only 1 instance). Does anybody know a way how to have multiple ThreadPools inside a...
13
by: orekin | last post by:
Hi There I have been programming C# for a couple of months and am trying to master Threading. I understand that ThreadPool uses background threads (see code example in MSDN page titled...
7
by: Sin Jeong-hun | last post by:
Hi. I'm writing a Client/Multi-threaded Server program on Windows Vista. It worked fine on Windows Vista, but when the server ran on Windows XP, I/O operation has been aborted because of either...
5
by: =?Utf-8?B?RkxEYXZlTQ==?= | last post by:
I'm developing an application that gets data from 100 sources (via telnet connections, but you can think stock quotes from a webservice if you like). I was planning on using the thread pool (25...
3
by: UltimateBanoffee | last post by:
Hi, I'm using asp.net 2.0 and I have an understanding issue here! I don't quite understand when the available threads in the ThreadPool are ever used. The application I have running doesn't use...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.