VS 2008 [Multi-threading] How To Run This Code In A Separate Thread
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
ADVERTISEMENT
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
Oct 27, 2011
I have a few forms that have a lot of really intensive updating along with a great deal of user interface (text boxes, button clicking etc) Is it possible to open a separate form as a separate UI thread from the start up form that called it to "show" or open or whatever the new method might be?
View 6 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
May 7, 2011
I'm trying to dive into what I consider a deeper end of VB.net to see how far I can go with it. I have a project created, ironically called "My First Server". The aim of this is to create a server which can handle multi clients but additionally isn't the commonly shown tutorial setup of a console application. So it is created as a Windows Form application. The main form (Public Class PrimaryForm) consists of only one control which is a listbox control. This is named LogOutput.
[Code]....
View 7 Replies
Oct 11, 2011
Wheres my error on this code...
Imports System.Net
Imports System.Threading
Public Class Form1
[CODE]...........
Basically what I want to do is that User will select how many thread w/c is the PickThread.value, then it will do the stuff.
View 11 Replies
Jul 29, 2009
Multi-Threading. I have got a simple bit of code that will need to be repeated but with a chance of it overlapping the only complex bit is there will be a varible that will be different each time. so I was wondering if I put it in another Thread and store the varible within the thread code would that achieve what I am looking for? To make it slightly easyier once the thread is started and pulled the Varible in there will be no cross talking between the thread and main app thread (ie no progress reports, no aborts/suspends etc) Nothing will be feeding back on thread completion either, when it ends it ends.
This is what I have so far:
Imports System.IO
Imports System.Threading
[CODE]...........................
View 5 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
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
Jul 20, 2010
The coding that I have a problem with might make people think that I am creating some malware. So the project I am doing is associated with iTunes. iTunes allows people to have one library. There is another way, but it is very confusing to some people, and very unreliable. So my project is that I will allow people to have multiple iTunes libraries on one computer. So the problem is this. In order to have an option to choose your library, I gotta make sure that iTunes is not running.
So this is the script:
Private Sub CheckAndCloseiTunes()
retry:
'Custom class that includes the function to safely close iTunes
Dim Processes As Process() = Process.GetProcessesByName("iTunes")
[CODE]...
So when I use the Threading.Thread.Sleep(2000) code, the form becomes unresponsive.
View 4 Replies
Jun 10, 2010
im trying to terminate a threading.thread using thread.abort the thread runs a download connection so is usually in the middle of socket.recieve or socket.send or socket.connect when aborting i just want to terminate the thread no matter what thread.abort raises an MDA excpetion. so i ticked it off in the debug exceptions menu. now it doesnt raise an exception, but the thread simply wont terminate. my program wont close unless i press top in the debugger.i cant pause downloads because i cant terminate the thread this code wasn't working?
Dim vT As Threading.Thread
For Each vT In clsDownloader.DownloadThreads
If Not vT Is Nothing Then
vT.Abort()
[code].....
as for the exception concerning threads being aborted from other threads being dangerous, how is it possible to send a message from a main thread to another thread to abort itself? as far as i know the only way to a abort one thread from another is to just kill it (because i dont know of ways for a thread to communicate with another).
View 2 Replies
Mar 16, 2010
What do I want to achieve: I want to perform some time consuming operations from my MDI winforms application (C# - .NET). An MDI child form may create the thread with the operation, which may take long time (from 0.1 seconds, to even half hour) to complete. In the meantime I want the UI to respond to user actions, including manipulation of data in some other MDI child form. When the operation completes, the thread should notify the MDI child that the calculations are done,so that the MDI child can perform the post-processing.Should I use explicit threading (i.e., create explicit threads), thread pools? Or simply just propose your solution. Should I create foreground or background threads?And how does the thread communicates with the GUI, according the solution you propose?
View 7 Replies
Feb 17, 2012
Would anyone be able to help me here please. I'm fairly new to VB.net and threading so im just trying to figure out what is happening.When I debug this I am getting the error thread operation not valid: Control 'ProgressBar1' accessed from a thread other than the thread it was created on.
I'm a little lost as to why the error is occuring or how to fix it. I've had to put the progress bar in a separate thread otherwise the GUI crashes
[Code]...
View 2 Replies
Apr 22, 2009
after i get a successful ping response i need to send an HTTP request to the device examine the response and then display it. i'm trying to multi thread the 2nd bit with no joy so far.
Imports System.Net
Imports System.Net.NetworkInformation
Imports System.Threading
[code].....
View 2 Replies
Jun 5, 2009
I would like some advice on multi-threading. I currently utilize two threads, one for the GUI, and the other for calculations. This works well, but I want to improve my multi-threading techniques. Currently the data is with the calculation thread, and this occasionally this will cause a slow down. I want to put the data on its own thread. Giving me three threads, Data, UI, and Calculations. This should improve responsiveness, and not be overwhelmingly complex.
My problem is, this no longer fits into the parent child relationship well. All three threads need to interact with each other. My question is, what is the better way of dealing with more than two threads, when all the threads need to interact with each other. Should I pick one thread as the ultimate parent, say the data thread (I pick this one, because it seems to me this thread will be the most free.) Then have the calculation thread and the UI thread children of the data thread. Then when I have a need for the UI thread to explicitly call the calculation thread, I do this through a function in the data thread.
View 2 Replies
Jan 27, 2010
I am instantiating a form object in my code behind the dataset just to access some form level variables and to occasionally set a label in the navigator bar. Recently in the b2 Team version of VS2010 there are some strange errors thrown in the immediate window and then I'm tossed out of debug mode and back into the IDE. This code has been operating for some time in this project without this behavior. A team member has just reproduced the behavior in his development machine also.The error that starts the shutdown of the debug instance is this: Control accessed from a thread other than the thread it was created on.
View 4 Replies
May 14, 2011
I have a need to build an app that will access about 10 websites and pass data to them, etc.I've read about something called multi-threading when searching Google. I've also seen people say that they use multiple browsers.Which route is better to use? I figure if you have to do some sort of multi-threading that you would access a single browser?
View 2 Replies
Mar 13, 2010
i got inside
WebBrowser1_DocumentCompleted sub
the code below
WebBrowser1.Document.GetElementById("form").InvokeMember("click")
Call ProcessNextLine()
when it clicks this button it should load another page(Like log in)
Call ProcessNextLine()
takes next line from txt file (It's url) + navigate
but I want it to wait let the page load before calling "Call ProcessNextLine()" I tried System.Threading.Thread.Sleep not working?
View 12 Replies
Apr 25, 2012
What is the difference in using: BackgroundWorker1 or System.Threading.Thread
View 3 Replies
Aug 22, 2009
I cant get System.Threading.Thread.Sleep to work..[code]
View 2 Replies
Jun 25, 2010
Im working with and trying to run an infinite loop on a new thread which at some point takes action (e.g. make changes to Viewport3D). But no matter what I use:
- BeginInvoke
- Background Worker
- Timer
I run into problems. My porblems are:
[Code]....
I am doing all this in WPF.
How can I run the loop in the background and get it to affect the Viewport3D controls content without throwing an error or freezing up the application? A Viewpoirt3D is a control in WPF.
View 5 Replies
Jul 19, 2011
I've been trying to use "System.Threading.Thread.Sleep(15)" as the delay code but if freeze the form. I used this "Location.Refresh()" where location is the name of the form, but it didn't give me what I need. This code is going to work on a ProgressBar while typing and the value of the progress bar change while typing. The progress bar jumps to the new value and I want it to move. So I thought about puting it in a "For ... Loop" but the whole form freezes.
[Code]...
View 1 Replies
May 14, 2011
I have a need to build an app that will access about 10 websites and pass data to them, etc.I've read about something called multi-threading when searching Google. I've also seen people say that they use multiple browsers.Which route is better to use? I figure if you have to do some sort of multi-threading that you would access a single browser?Not sure which way I should approach this app.
View 2 Replies
Sep 17, 2009
Is it possible to start a timer on a separate thread so it doesn't block the user interface, or do I have to make a thread that I call from the timer?
View 2 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
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
Mar 10, 2010
VS 2008 Multi Thread Overload resolution failed
View 10 Replies
Dec 31, 2010
I'm reading data from a serial port, but the DataReceived event of SerialPort is handled on it's own thread. I want to handle this on the main thread, but simply declaring an event and raising it still results in it being processed on the SerialPort thread. I'm assuming I need to declare a delegate I can call, but I don't see how that would work.
For example, I want to call Sub HandleDataReceived() on the main thread from the DataReceived thread, having HandleDataReceived() run on the main thread. How would I do this?
View 1 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
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