Multi-Thread Not Working?
Apr 22, 2010
I had followed the Example on mulit-thread in MSDN, but add a loop in my implementation. But seems like the multi-thread is not working.
Private
Sub
SboE_Start_Btn_Click(ByVal
sender As
System.Object,
[code]....
View 1 Replies
ADVERTISEMENT
Sep 30, 2009
I'm trying to get a VB2008 multi thread application working that connects to a local server program using sockets. Server requests for this particular system can be more quickly handled by a number of connections, so I've written some code to run any number of data request threads that I choose. The problem that I'm having is that the data returned from the server is getting mixed up and is often returned to a different thread/socket than the one that requested it. Other than that, it seems to work okay. If I use just one thread, then the system works as it should. Pls. see incuded code, which is heavily edited to remove all the other fruit salad. Is there any way to set up the sockets so that data returned to the socket/thread that requested it?
Module StaticDeclarations
Public WithEvents g_SD As New SocketDataClass(New MainThread.MTCallback(AddressOf MainThread.MTResultCallbackSub))
Public WithEvents g_MT As New MainThread(New SocketDataClass.SDCallback(AddressOf SocketDataClass.SDThreadResultCallbackSub))
[code]....
View 4 Replies
Feb 10, 2010
I'm adding multi-threading facilities for the first time. I have a function that is wrapped to be run in a separated thread. This function retrieves data (text) from a combobox and it works for sure without multi-threading.
When I call it as multi-threaded, I get the following error when I try to retrieve the data from the cmobobox: Cross-thread operation not valid: Control 'cmb1stBL' accessed from a thread other than the thread it was created on.
It looks like a restriction of thread-safety... I assume that the child thread cannot read from his parent, to make sure that he doesn't change his parent data. So how can I read the data from the combobox? Should I read the comoboxbox data before calling the child thread?
View 4 Replies
Oct 11, 2011
As we know, one STA UI thread creats the controls only canbe accessed in the UI thread in Winform application. And we need to call control.invoke or begininvoke to run the code in the background thread.
Yes, below code in VB.Net , VS 2010 Winform project can throw the exception "Cross-thread operation not valid: Control 'Form1' accessed from a thread other than the thread it was created on."
[Code]...
View 9 Replies
Mar 22, 2010
Im trying to do this
[Code]...
But it will just skip to the last status (Label3.Text = "Status: Welcome")
View 7 Replies
Oct 19, 2010
I'm experiencing an error which complexity and way to approach I can't quite understand.. It looks like two threads not able to work simultaneously.The first thread is the normal program thread, and the problem occurs when the user clicks a button. This sends some messages through a method (PlaceOrder) of an API library object. This method is called 2-3 times in a loop. Handlers have also been added (on program startup) to receive callbacks on events raised by that object, and this is the 2nd thread that contributes to the error.
The error seems to occur when the PlaceOrder method is called while receiving an event from this same object.The result is that the UI freezes. I can trace the error in two places. If I trace the first thread (which is the initial program thread); the freeze occurs when reaching the lock(this) line, in the API-object class. If I trace the callback event, the handlers of this event try to invoke a RichTextBox on the form, and the freeze occurs on the line <RichTextBox>.Invoke(....), as indicated below.
The thing is that when pushing the button, there is a loop which calls the method of the API-object 2-3 times. And the first time succeeds, but the 2nd time it seems to crash in some way with the callback. It would be nice if I had made some silly mistake with the invoke code, but I don't think I have, as it updates fine prior to the error.. I'm not sure, but it may be relevant that it's in fact the same object, so early in my program I add this event listener (which is the one that updates the RichTextBox):
AddHandler ibclient.Error, New EventHandler(Of ErrorEventArgs)(AddressOf client_Error)
..while later, related to the freeze, I have:
ibClient.PlaceOrder(....)
But I'm handling a lot of calls forth and back other than these, and haven't experienced any problem before.it doesn't give any exception or error message, it just freezes.The invoke stuff in the form code, which should be as per trusted examples: (Freeze occurs at blue highlight)
Private Delegate Sub SetRichTextBoxInvoker(ByVal message As String)
Private Sub OnLogUpdate(ByVal message As String)
If Me.rtbTwsMessages.InvokeRequired Then[code]........
View 9 Replies
Feb 8, 2011
How do i go about multi-threading that, it's just an example project, so i can try and learn from it. As i'm having a hard time understanding JMC's tutorial as it doesn't directly relate to what i'm trying to do [code]When you hit 'Start', the start button is disabled and the Label1 then changes to "Downloading".The data is then downloaded and put into the Textbox1.Label then reads "Complete" Start button is enabled.
View 5 Replies
Dec 17, 2009
i know that a single function could not be run until it has finished and is currently not running. what if i have 2 functions within a class, are both of them allowed to run simultaneously? or will running 1 of them prevent both of them from running until it is done?(assume that backgroundworkers and threads are running the functions of this class)
EDIT: plus what if a single function has multiple signatures, is it considered a single function or 2 different functions? could both of them be running at the same time or only 1 is allowed to run between the 2 at any one time?
View 13 Replies
Feb 29, 2012
Has anyone any ideas of what these errors mean and how to fix them?
Error 1 Overload resolution failed because no accessible 'New' can be called with these arguments[code]...
View 3 Replies
Jan 21, 2012
this is my first post and my knowledge of Visual Basic is still in its infancy (this is my first real attempt at app that is any use) however I am trying to develop an application to delete user profile and home directory folders.
I have the application working but the problem is with the application hanging (I understand this to be due to it running as a single thread and the main form gets ignored while the deletion is occuring) during the deletion process, I have tried various ways to resolve this such as starting the delete procedure as a new thread but cant get it to work without the hang.
[Code]...
View 1 Replies
Jun 2, 2011
i want to process a list of strings using multiple threads. the first function pases it, it then send the result to another, and finally that one displays the final result in list view
dim items as new list(of string)
private sub button_click()
start parsing thread
threadParse = New Thread(New ThreadStart(AddressOf startprocess))
threadParse.Start()
[Code]...
View 7 Replies
Mar 17, 2009
I have an application which is working. Basically you put in the PC name/ip and it returns the logged on user. I am happy with this part. There is also an option where the program can read a text file of PC's. It will then create another text file with the name of the logged on user next to each pc. This part works, however the program is non-responsive during this time (there is a progress bar, so you can tell it hasn't stalled). I would like to multi-thread this part of the app if possible, Just starting the related sub procedure as a different thread would be a great start - I'd like to start a new thread for each pc in the list to be scanned (if this is recommended) however I imagine this might be slighly complicated...The part I'm referring to is the Sub Procedure "ReadFile". This then calls the Sub Procedure "CompareUserList".
View 2 Replies
Mar 10, 2010
I'm trying to multi thread for first time and I'm getting this errorError1Overload resolution failed because no accessible 'New' can be called with these arguments:
'Public Sub New(start As System.Threading.ParameterizedThreadStart)': Method 'Private Sub WebBrowser1_DocumentCompleted2(sender As Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)' does not have a signature compatible with delegate 'Delegate
[code]....
The code works fine without multi threading?
View 1 Replies
Nov 29, 2011
I was going to hijack another, related, thread to ask this, but I figured it derserved its own thread.The question I have is whether or not anybody has done sufficient testing to show whether a mutlithreaded program running on a multi-core system will spread the threads across all available cores, or whether it has some affinity for the core used by the main process (UI thread, or whatever it may be)? The reason I ask is because I remember a discussion over in General Computing where somebody showed that, for at least one case, all the threads were splitting time on a single core of a multi-core processor. I am wondering if that is the typical behavior, or an isolated case?
View 23 Replies
Mar 15, 2011
i want to use multi thread facility to fasten my calculations. My code is the following:
[Code]....
I am addding items into "string.list" until it counts to 1.000.000. Then i do some calculations in "for each" and "sonuc_listesi" only returns one string. After that; i insert that string into the table in sql. finally i clear both the "sonuc_listesi" and "string_list" to do the new items.
i want to do this with multi thread. For example; when "string_list.count" is 1.000.000; it will be divided into 4 thread working at the same time having 250.000 items individually and inserting their own result (one string) into the table in sql after the calculations. Then each will clear their own "sonuc_listesi" and "string_list". If one of them finishes earlier; it must wait the others get finished.. i hope i clarified well. How should i do this? Is tihs current method is structurally enough to do thread or should i make sub or function?
View 2 Replies
Sep 18, 2011
this is going to be hard to explain but ill try. Question 1. Ok i have a list box with a few items, What i want for this example is to click a button and it will start on the first item and do: MsgBox ("this is item blah blah blah") then after that it will go to the next item and do the same and then the next and so on untill all have been done. The "blah blah" should be the item so if item was to say "hello" then the msgbox would say "this item is hello" I know this would be a lot of msgboxes to close, like if 50 items then thats 50 msgboxes to close, this is just for the example.
Question 2. Ok this is where ive tryed to learn but find it really hard (multithreading) Im wanting all to be multithreaded so all work at the same time, ive tryed a few times but the only way i see it is having a **** load of subs, like if i want it to use 10 threads then ill have to add the same code 10 times or somet, im not sure.
i have attempted all this and failed big time as my way was to get the first item and use that then remove it from the listbox BUT... with it being quite fast the 2nd 1 and 3rd 1 used the same item befor it was removed and to be honest i dont really want them removed. so my attempts took like 2-3 days that was a waste of time really. I Know this is a lot to ask but im in real need of it and these 2 things have driven me half mad.
View 21 Replies
Feb 21, 2012
I want to make my client & server fully working. If a client connects to the server it should tell that there is a new client connected. if a client disconnects it should tell me a client disconnected.[code]it says in my patcher window(where it should add the text) that it's succesfully connected.but at the server side its not saying there is a new client connected/disconnected, how can I do this?
View 2 Replies
Mar 27, 2012
For downloading a number of images I'm making DownloadDataAsync calls to separate instances of WebClient, in a loop, with a thread sleep delay. I expected the response to happen on separate threads, but it seems not, as response only occurs after all calls are completed.
So what's an appropritate fix for this? Is there an alternative client type, or should I make a thread for each webclient call?
So currently I'm calling this in a loop:
Private Sub StartDownload(ByVal webImageLink As String, ByVal token As Object)
Dim wc As New WebClient
Try
[Code]....
View 1 Replies
Aug 25, 2009
I looked around the site and the questions I found relating to this subject were for C# (the application that I am maintaining is written in VB.NET), so I apologize if I overlooked one. Here is where I am calling my thread:
[Code]...
View 5 Replies
Mar 10, 2010
VS 2008 Multi Thread Overload resolution failed
View 10 Replies
Apr 21, 2009
I am creating an IDE for a game script with similar functionality as the Visual Studio IDE (at least, some of it). The game script consist of code that looks visually a bit like C code. It uses braces to define the start and end of a 'class' and uses nested braces to define the start and end of an 'event' in a class.
What I want finally is to have two Comboboxes above the text editor, one that lists each Class and the other listing each Event. The comboboxes should also show the Class and Event that the caret is currently in, just like in Visual Studio.I have attached an example of such a script (you can open it with Notepad).However, here is a short example where you can also see how I "defined" classes and events:
class1
{
event1
{
[code]....
As you can see, the classes are the 'names' of each block of code, defined by matching braces { }. The events are the names of each nested block of code, also defined by matching braces { } but inside a class. There is only one level of nesting.As you can also see, the layout can follow the standard C-style layout, or a slightly different layout (using the opening brace on the same line as the class/event name), or even a completely chaotic mess. As long as the braces match correctly, the code is valid.So in short, the large blocks are classes, while the nested blocks are events.
What I want to do, is parse an entire script, and store all the Classes (and eventually, also all the Events, but let's forget about them for now). I want to store the Class name, start position (defined as the start index of the name), end position (defined as the index of the closing brace) and the full text (defined as the text between start and end position, so including the name).
vb.net
Public Class clsClass
Private _Name As String
[code]....
The code works basically by finding every first opening brace (the opening brace of each CLASS, not event), and then loops through the class (using a brace counter to keep track of the nested braces) until it found the last closing brace. It then stores the name, start, end and fulltext in a new clsClass and adds it to the list to return.
View 3 Replies
Sep 11, 2011
How can I make my apparently so that when I click a button, it executes a sub of my choice on a seperate thread? I need this to send an email and when I ran it normally it crashed my GUI.
View 1 Replies
Sep 13, 2008
I am using a background thread in my application. The problem is: this thread starts when a button is clicked and it works well. After finishing it's work i can see the result. But when i try to start again, it gives me an error. How to restart a thread?
[code]...
When i press ToolStripButton1 for the first time it works really well. But when i press it second time it shows me error that, the thread has already been started.How to resolve it? I think how to restart thread is my question.
View 2 Replies
Jun 28, 2009
It is my previous problem in vb6, its hard to multithread using vb6 so I migrate my codes to vb.Net.How can I multithread this two loops so that this process is running at the same time.Because when I start my second Loop, my first loop stop in executing. It will start again when my 2nd loop finished.
[code]...
I have 2 connected GSM Modem in usb port.That codes will send SMS in all contacts in my ListBox.
View 27 Replies
Dec 4, 2009
I have a console application (VB.NET). When it is started, it spawns worker threads to find work in the database and do the task, then look for the next task (A workflow basically).
The problem that I have is that I have my Event Handler in the main thread that spawns the worker threads. Those workers, if they error, raise an event to a public delegate. However my main thread is not detecting these events, and I cannot figure out how to make it. My intention is to do all logging (text/database), email alerts, and restarting the worker to find another task that is not errored. (This will be expanded in the LogErrorMessage routine and such, for now I am just keeping it a simple Console.Writeline so that I can see if the method is being fired or not)
Here is the code around what I am trying to do:
Logger Class:
Public Delegate Sub LogDelegateError(ByVal Ex As Exception)
Public Class EventLogger
Public Event EventError As LogDelegateError
[Code].....
View 2 Replies
May 27, 2011
I have a class that creates a ticker whose tick event checks somes stuff for me. If I instantiate the object and call the methods it works just fine. however if I create a new thread and call the function then the tick event doesnt get called for some reason.
Calling the object/creating thread:
Dim checkObj = New checkOutLook
checkObj.delForm = Me
[Code].....
why it would have problems handling an even tick on a separate thread? I even added a MessageBox output in the ticker to be able to check that its working properly
View 1 Replies
Mar 29, 2010
Well to simplify it, whenever I use sendkeys from a background thread it just doesn't work. I even created a textbox, button, and backgroundworker with the following code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
[Code].....
View 4 Replies
Aug 5, 2009
I have a background thread that calls a subroutine with the following inside it. I'm assuming the thread is messing with this part since it doesn't return anything.
Dim ctl As Control = Me.GetNextControl(Me, True)
Do Until ctl Is Nothing
If TypeOf ctl Is TextBox And ctl.Enabled = True And ctl.Tag <= 36 Then
[Code]....
I just called the sub that this is in without using the thread and it works fine, so it is the thread. How can I get this working inside a background thread?
View 1 Replies
Oct 24, 2010
I'm trying to create a CBT hook to an application, in this case Notepad.
[Code]...
EDIT: I have also tried it on a Windows XP system now, and it doesn't work there either.
View 2 Replies
Feb 2, 2012
I am using Visual Studio 2010 and have been slowly getting into threading. My current project has a form with a button that in turn starts two threads. The form itself has two labels on it that are used to display the progress of the computations. Each thread has a delegate defined to change the value of the respective label (as the labels are not defined in the thread, but on the form itself). The threads call subs from a separate class. All of the calculations work flawlessly. My problem is that the labels do not visually update. Through use of message boxes at the end of each loop, I know that the label text property is, indeed, being changed, but it is not actually refreshing and updating on screen.
My delegate code is as follows (I grabbed this code off of another forum where people had the same issue - it seemed to work for them, but not for me):
Private Delegate Sub UpdatePMLabelTextDelegate(ByVal s As String)
Private Sub UpdatePMLabelText(ByVal s As String)
' Are we in the same thread as the label itself?
[Code].....
View 9 Replies