Is Running Multiple Threads Faster Then A Single Thread On A Single Core Cpu

Dec 23, 2009

Say I have a code with 3 methods that do some pretty intensive work. Would executing these methods on 3 seperate threads be faster then executing them one after the other on a single core cpu? And what if it's a dual core or HT?

View 8 Replies


ADVERTISEMENT

For Loop CPU 25% Single Core

Oct 15, 2010

For loop CPU 25% single core

View 6 Replies

Using Multiple Threads For Faster Execution?

Jan 27, 2012

I have a map image with data associated with the map indicated by RGB index. The data has been populated into an MS Access database. I imported the information in the database into my program as an array and sorted them to go in the order I want the program to run.

I want the program to find the nearest pixel that has a different color from the incumbent pixel being compared. (Colors are stored as string attributes of object Pixel)

First question: Should I use integers to represent my colors instead of string? Would this make the comparison function run significantly faster?

In order to find the nearest pixel of different color, the program begins with all 8 adjacent pixels around the incumbent. If a nonMatch is not found, it then continues onto the next "degree", and in this fashion, it spirals out from the incumbent pixel until it hits a nonMatch. When found, the color of the nonMatch is saved as an attribute of incumbent. After I find the nonMatch for each of the Pixels, the data is re-inserted into the database

The program accomplishes what I want in the manner I've written it, but it is very very slow. After 24 hours, I am only about 3% through with execution.

Question Two: Does my program behavior sound about right? Is this algorithm you would use if you had to accomplish this task?

Question Three: Would it be appropriate for me to use threads in order to finish execution of the program faster? How exactly does that work?

Question Four: Would it be more "intelligent" for my program to find the nonMatch for each pixel and insert it into the database immediately after finding it? (I'm making a guess that this would be good in multi-threading, because while one record is accessing the database (to insert), another record is accessing the array of pixels (shared global variable in program).

Question Five: If threading is a good idea, I'm guessing I would split the records up into more manageable chunks (i.e. quarters), and have each thread run the same functions for their specified number of records? Am I close at all?

View 3 Replies

Cross-thread Operation Not Valid Exception In Single Thread Application?

Nov 14, 2009

I am getting this exception: Cross-thread operation not valid: Control 'TextBoxOutput' accessed from a thread other than the thread it was created on. in a VB 2008 Windows Forms application that I havent specifically made multi-threaded. I have create a sub called Out() like this:

Private Sub Out(ByVal inString As String)
Me.TextBoxOutput.Text += (Me.TextBoxOutput.Text & inString & vbNewLine)
Me.TextBoxOutput.SelectionStart = Me.TextBoxOutput.Text.Length
Me.TextBoxOutput.ScrollToCaret()
End Sub

and I call it from various events to log messages I am getting from my pbx, which I use a third party open source dll to access. The interesting thing to me is that if I run the deployed application (ie, not in the VS IDE) I do not get any exceptions, it's only from within the IDE.if I add the line: Control.CheckForIllegalCrossThreadCalls = False to the form's constructor, the exceptions stop, but a) this seems like a hacky way to get around the issue and b) the application seems to hang sometimes when I have it set this way.

View 2 Replies

Current Thread Must Be Set To Single Thread Apartment Sta Mode Before Ole Calls Can B

Apr 21, 2010

I'm getting the following error:"Current thread must be set to single thread apartment sta mode before ole calls can be made"

I am using Speech.Recognition.SpeechRecognizer and using it to open various dialog boxes. It works fine for the first few but on the third one when it calls the InitializeComponent in the Dialog's New, it throws the above error.

Anybody have any clue what causes this or how to fix it? The SpeechRecognizer seems to run on its own thread, so that seems to be at the root of the problem. If I open thedialog with a button click I don't get an error.

[Code]...

View 1 Replies

VS 2010 Backgroundworker Thread Running Faster Than The UI Can Update Progress?

Nov 15, 2011

I have a VB.NET 2010 app that uses a backgroundworker to process MS Word docs. All of the code does what it is supposed to do, except when my code calls ReportProgress(). The UI cannot process the ProgressChanged event fast enough before the values in the class that are passed are changed. I know this because I inserted a System.Threading.Thread.Sleep(100) line after each ReportProgress() call which allows time for the UI to make the updates properly. I guess I am looking for a better solution thanThread.Sleep(100) since this adds to the amount of time it takes to process all of the files. Here are some snippets of code that I am using:

[Code]...

View 5 Replies

Running All Threads Not On The GUI Thread?

Dec 7, 2011

I have only managed to use an STA to run a long running excel process with a background worker and 2 delegates.

What I want to do now is have the whole application running outside of the main thread to make sure the UI is always available, I then want to create new threads from the thread I have outside of the main to run the various processes. I will need to have some form of syncronisation in there for certain things to be done once a thread is completed and also I will need to change the button states on the main form to stop certain process being called whilst other processes are running.

This is my code so far, basically this loads in a csv file to a datatable adding manager employee ID and email address, filters it and displays the resultant data in a listview. There eventually will be some filter options as well. There are then 2 options for processing the data, it will produce individual bradford factor reports and email them to each manager or will produce a summary spreadsheet that is sent to HR.

Currently because there are around 8000 lines of data, it was the summary option that required the background worker as a long running process time out error was occuring whilst in the main.

What it does is write the data from the list view to an excel sheet and colour co-ordinates the summary rows according to the absense policy. It then copied bottom to top, the summary value the next blank column against all the lines for that individual and then uses this column to decide which sheet to move the row to, copying the row to the new sheet then deleting it from the master list and shifting the cells up.


This works well, but the process of loading the data in to the list view locks up the main thread where it currently runs. I also wanted to make this slightly more complicate as far as threading is concerned, as more of a learning curve than a practical application of the function.

Here is my code so far: [URL]

View 10 Replies

Running Threads In Thread.Pool Sequential?

May 19, 2012

I have several threads in my WinForm and I am running them via Thread.Pool, what I need to know is that how can I run them sequentially.

example:

Thread1 => me.label1.text = "Thread1"
Thread2 => me.label2.text = "Thread2"
Thread3 => me.label3.text = "Thread3"

In my Form_Load event, I have a line as follows:

[Code]...

View 8 Replies

Querying A Single Column And Displaying All Results In A Single Textbox?

Sep 5, 2010

I am trying to make a list, separated by a comma, of entries from a single column in a SQL database. I have been spending the last several days searching for a way to do this, but every thing I found either didn't work, or wasn't exactly what I was looking for.

The query will pull all the email address that are not null. What I need to know is how to take the result of that query and make it look like this:

email0@address.com, email1@address.com, email2@address.com, etc, etc, ...

I feel like I should know this, but for the life of me, I can't remember nor can I find it in any of the textbooks I have.

I am using Visual Basic 2010 and SQL Server 2005. I also have access to Visual Basic 2005 if needed.

View 2 Replies

SqlCommand Parameter / Replace A Single Quote With Two Single Quotes

Oct 23, 2009

I use SqlParameters when executing database statements. I know that I can replace a single quote with two single quotes... but in the past SqlParameters took care of this for me. I have two projects.. in one, the SqlParameter does this and it handles single quotes fine, in another, it does not and I'm at a loss why (I even copied and pasted the code):

[Code]...

View 9 Replies

VS 2008 Bind A Single DGV Cell To A Single Class Property?

May 7, 2010

I am trying to use the DGV to view various properties from a variety of different class instances. Is it possible to bind each cell individually?

View 9 Replies

Classes Are Single/multi Thread?

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

Update A Single Row And A Single Cell In Ms Access Database?

Dec 3, 2010

I am trying to update a row or a single cell in ms access through vb.net. But when i update the text box named NRIC, say for example i want to update "s4522147B" to "tr4521856C" and mean while leaving the other fields the same.

But the thing is when i make the changes in nric.text (textbox), the dataset actually updates the whole column in the table instead of the selected textbox.

Below is my code for the update part

[Code].....

View 3 Replies

Cross-thread Exception When Coding Single Threaded?

Jun 5, 2011

I'm having a small issue; I start a process and when that process exits, I raise an event which removes a control from my form.It all works perfectly until the part where I want to remove a control from my form. Visual Studio gives me a cross-thread exception even though I'm programming single threaded.

View 6 Replies

VS 2008 : Binding Single Object To DataGridView, Update From 2nd Thread?

Oct 15, 2010

With the DataGridView I'm used to just populate them with a list of some object, using the DataSource property. Now I want to just display properties from a single object, and I'm a bit confused on how to do it.. The object is updated through an API event, and I want to select some of the properties for displaying in the DataGridView, to look like this:.where "ValueX" is the name of the properties.Now, what would be my options for binding this to the DataGridView, such that property changes are automatically updated. Since an update also must invoke the control, does that mean I must reassign all bindings, or what logic is necessary in this case?

should I bind to an array, arrayList, stringList, dataTable etc? I guess I'm not sure which type of source will allow binding. Or if I should perhaps build the columns and cells of the grid and populate them "one-by-one" to the properties of the object?

View 6 Replies

.net 2.0 Multiple Programs Each Running Threads On Xp, Will .net 2010 Be Better?

Oct 2, 2010

In the past few weeks, to speed up our database freshening process, I've created a couple of extra programs, basically copies of the exe file. The program itself, accesses web pages, images etc and uses threads to do so. The second program uses LIMIT 300,100 and the third LIMIT 600,100, to make sure they don't work on the same records.

Before the last few weeks, one occurrence of the program used to run without problem, from the task scheduler all through the day. Only one occurrence of each exe can run at a time.Since theres now three programs running, .net 2.0, on xp, the program often seems to get stuck and never ends. I have to kill it from task manager.

It runs fine in the IDE I just wonder if there would be any benefit from upgrading to vb.net 2010 ?

View 1 Replies

Multithreading - Code For Running Multiple Threads?

Apr 17, 2010

How to I run multiple threads in VB.NET? Say I need 2 threads - one that prints 100 numbers in a loop and the second one that asks for the user's name and prints it inside a message box.

View 1 Replies

Running Different Processes In Multiple Threads Without Overlapping

Jan 13, 2012

I have a sub-procedure which I want to run a different process, depending on what is currently running. I thought the easiest way to do this was by using an ArrayList of each of the campaign details & adding an 'Inuse' field to check to see if the Inuse field is set to 0 or 1. The problem that I have is that when running the process it is all happening at once & the integer hasn't been changed before the next thread kicks in so my threads are running the same campaigns. I tried to avoid the problem by adding a Thread.Sleep(100) delay inbetween starting threads but this led to exactly the same problem.

Here's an example of what I am trying to do:
Imports System.Threading
Public Class Form1
Private Campaigns As New ArrayList
Private ProcessRunning As Boolean = False
Friend StopProcess As Boolean = False
[Code] .....

View 2 Replies

Passing Command Line Arguments To Already Running Single Instance App

Jan 19, 2010

I have a single instance database app that emails out notifications. I would like to add a link in the emails that when clicked would open up the app and go to the section of the program that its supposed to go to. I implemented my own URL protocol so that links starting with my codewords get passed to my EXE. So far so good. I then parse the URL and pull the keyword and identifier out to open that section of the program. So if a user clicks a link like this:

MyApp:LoadCompany?ID=323

My application will start, it will grab the arguments (LoadCompany?ID=323), pass this to my load company routine and then load up company ID 323. Works great.

Now the issue is if the program is already open I still want the links to work but since it's a single instance app it just closes the second app. How can I add something ot the app to watch for this or receive a message from the second app? I know I will need to check status of what I'm doing and make sure things are saved, check security, etc but I can get all that done easily enough. I've found some examples online but none really did what I wanted them to.

View 8 Replies

Possible To Split Up Threads (currently 6) So That 3 Run On Each Core?

Oct 18, 2011

I have a VB.NET app that spawns several threads for performing XML parsing/database interaction. Only one of my cores (only have 2 currently) is being used right now.I've looked at Task Parallelism in .NET 4 but I need to be able to start a task at different times (not all at once).Is it possible to split up the threads (currently 6) so that 3 run on each core? Also, if I don't want to limit my threads to 6, how can I check CPU/memory programmatically to find out if I can start another thread.

View 2 Replies

Execute Multiple Scripts At Same Time, Running On Own Threads?

May 6, 2009

I'm writing a scripter using VBScript, that should be able to execute multiple scripts at same time, running on own threads.
The issue is, I DO start those scripts on different threads, but their sleeps still seem to affect the other threads too.

For example, let's say I start 2 scripts

In the Main event
NewScript1
NewScript2

[code]....

View 1 Replies

Office Automation :: Outlook - Application Running Multiple Threads

Apr 15, 2009

I have an application, running multiple threads, and in many of these threads, Outlook is being called, some mails read, attachments downloaded, and then the outlook instance closed. But it is possible that there are a number of threads trying to do the same thing at the same time. There is of course a lock at the beginning and end of the process, so that no two threads try to access the outlook application at the same time.

"Sometimes" i get an error message : Creating an instance of the COM component with CLSID {0006F03A-0000-0000-C000-000000000046} from the IClassFactory failed due to the following error: 80010108

View 3 Replies

C# - .NET Multiple Namespaces For Single Class

Sep 27, 2010

Is it possible to have a single class reside within two name-spaces and how can I do this?

To clarify: We have a class library (let say root namespace is classLib1), which has grown over time (more classes) and I want to logically group classes into different namespaces. However some of the older classes need to be grouped into these new namespaces (e.g classLib1.section1) and doing so will break legacy code in other assemblys that use this class library. So I want to be able to refer to a class using both name-spaces until we can phase the old ones out.

I can't find any information on this, which suggests there is a reason that people would not want to do this!?!

View 3 Replies

C# - Using A Single DataSource On Multiple .NET Forms

Sep 16, 2010

My program has two forms which get data from the same data source. After binding controls to tables and fields on both forms, I noticed each form has it's own apparently duplicate DataSet. Is it standard practice for each form to have its own DataSet even though they use the same ConnectionString and connect to the same database at the same time?

View 1 Replies

Combining Multiple Projects Into A Single One

Apr 19, 2008

I originally developed a simple application software [VB.Net + MS Access] (Lets call this project A) but now I want to include more functionality in it. I have an encryption/ decryption software utility (Lets call this project B ) and a Text to speech generation utility(Lets call this project C) . That is, I want to add Projects B and C to project A. [Such that clicking on the main form of project A calls a form from project B or C as desired].In solution explorer, I right clicked--Add Existing Project--and added both the above mentioned projects 1 by 1. (Added B and C to the solution explorer with the already present A).As the application software's (Project A's) main form is the main form of my project, I want to have a menu option on the main form (Of Project A) so that a user could click on one of the menu options and the main form of my other projects ( Project B or Project C or Encrypt/Decrypt or Voice Generation) should open by him doing so. To this effect, I tried the following:

1. I dragged the form simply from one of the projects (From B or C ) into the folder of my Application Software (Project A).This generated a lot of Build errors and the Voice Generation utility (Prj. C) would not work like this.

2. Tried to reference a dll, however the authors of Projects B and C did not include a dll in their projects.

3. Now I came to know that to call a form residing in another project folder or even another folder within the same project, you have to give a path for the form. HOW DO WE DO THIS?

As you can understand, I cannot copy the entire code of the 3 projects here....I will try attaching my project here though..Here it is: http: rapidshare.co...MY_Prj.zip.html[Dear Administrator: The downloading option on the webpage does not allow files bigger than I mb, thts why I used an external link]As I said, in the application, Project A is TMS.NET ; Project B is EncryptFile and Project is C.I encountered a problem while adding project C [spoken word], so the project contains only projects B and A. I will try to attach project C seperately.That is, TMS contains proj A+B and Speech contains C.

View 4 Replies

How To Combine Multiple Matrices Into A Single One

Jan 12, 2011

I am trying to understand transformation matrices (not just their implementation in VB, but in general) and I've put about 3 full days into this so far. I believe I have the data in my matrices correct. Applying any single matrix to an array of points does a correct transformation.I am wondering if I understand how to combine multiple matrices into a single one.I understand you just have to multiply them together.I took this to mean you just have to multiply each element with its corresponding element in the second to make a third matrix?[code]

View 5 Replies

MDI Single Form Or Multiple Forms

Mar 7, 2010

I've written an application with about 30 forms and am almost ready to publish, my biggest concern though is that i'm not sure if its a normal thing to do having all these forms and hiding, disposing and showing forms throughout the use of the application.I've toyed with the idea of converting to a MDI Child / Parent interface as well as having one form with lots of subcontainers that are hidden and then hiding / showing them as the navigational buttons are shown.Ive worked on this application for about 8 months now, but would be happy to rewrite the interface and appearance of it if i know that it is not generally an acceptable practice having forms flashing open and closed while navigating through the application.

View 3 Replies

Multiple Operations Using Single RecordSet?

Jun 18, 2012

I have some task regarding do operations on database using ADODB in Vb.NET.regarding using the same record set multiple times?

I have tried on this topic just by closing the recordset after performing First operation and doing second operation e.t.c.

In ADO.NET we have "MultipleActiveResultSets=True" in ConnectionString for SqlDataReader.Do we have any property like this in ADODB?

View 1 Replies

Multiple Thumbs On Single Scrollbar?

May 10, 2011

I'm working on a project that involves using multiple scrollbars. Scrollbar1 displays the medium value and its thumb is disable, scrollbar2 displays min value and scrollbar3 displays max value. I can try to use three separate scrollbars to accomplish thetask but that doesn't look nice. Therefore,

View 3 Replies

Save Multiple Textboxes In A Single .txt?

Dec 4, 2011

ok i need a code to save multiple textboxes in a single .txt..

EX:
TextBox1.Text = ("Michael Rittenburg")
TextBox2.Text = ("United States")
TextBox4.Text = ("Nashville")
TextBox3.Text = ("Tennessee")
TextBox5.Text = ("37203")

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved