.NET Terminating Threads In An Orderly Fashion

Jul 26, 2009

Currently, I have a RingBuffer which is run by a producer and a consumer thread.In looking for a method of terminating them orderly, I thought I'd use a flag to indicate when the producer had finished and then check that flag in my consumer along with the number of ring buffer slots that need to be written. If the producer has finished and the ring buffer has no slots that need to be written the consumer can terminate.However, if I artificially lengthen the time the producer takes by inserting a sleep, the consumer does not terminate. I believe this is a consequence of the semaphores being used.Here is the code I'm working with. Notice that the program will "hang" after all slots have been written. The producer terminates, but the consumer "hangs".[code]

View 1 Replies


ADVERTISEMENT

ADO.NET: Return Multiple Values Instead Of Only The First In An ExecuteScalar()-like Fashion

Nov 18, 2009

currently, I use this code:

[Code]...

View 10 Replies

Write Xml Documents In A Linear Fashion Is To Use The XmlTextReader?

Mar 20, 2006

OverviewThe fastest way to read or write Xml documents in a linear fashion is to use the XmlTextReader and XmlTextWriter classes in the System.Xml namespace. If read- or write-only forward-only access is too limiting, however, the System.Xml.XmlDocument class provides the ability to easily modify existing documents (adding, removing, or modifying elements and / or attributes) and leverages the powerful search capabilities of XPath.

Getting StartedThe XmlDocument can load Xml from a string in memory, from a URL, or from a file path. There are two methods that enable this functionality: Load and LoadXml. To load a document from either a URL or file path, use the Load method. Following is an example of using the LoadXml method to load an Xml document from memory. (NOTE: we will be working with this particular document throughout this article)

[Code]...

View 4 Replies

Multithreading - .NET 4.0 Execute Multiple Threads But Threads Are Completed Before Resuming?

Oct 19, 2011

I just had a new, last-minute idea on to take on a task, so I am running to StackExchange for quick help.

What I want to do is execute a series of methods right in a row, each in their own threads. I want the application to wait until all of these threads are completed, after which the program will resume. It also has to use managed threading (thread pool).

What quick examples could you provide to help me along the way? If it's too complex, what things should I know about so that I can Google it on my own?

View 1 Replies

Queue Threads - Spawn A Series Of 'child' Threads From A Loop

Dec 30, 2009

I have a main thread which is designed to be a batch processor - it spawns a series of 'child' threads from a loop (which can vary in terms of the no of items) - see below

[Code]...

However, each of the 'child' threads could take anywhere from milliseconds to about a minute to process - depending on the complexity of each calculation. There may also be a large number of child threads - e.g 100s. Creating large numbers of child threads is not efficient. I therefore want some way to effectively queue each child thread (and cancel if the process is taking too long to complete). Autoevents seems like one way of doing this, but the only examples I can find seem to assume there are two different processes on seperate threads, not one process being repeated.

View 4 Replies

Background Thread Not Terminating

Jan 26, 2010

I have a program that if user presses a key(while the program isn't focused),it presses some keys(some kind of macro to aid gamers).The program works,but I cannot stop the background thread.I use "t.abort()" (t is the name of background thread) but it keeps working(even when I close all forms) and at TaskManager "keypresser.exe" is still there.[code]

View 5 Replies

Format Number With Terminating Decimal?

Oct 17, 2011

I have an internal process that requires data in a very specific format. Nothing I can do about that. So in my VB.NET program I am trying to output a number with a terminating decimal and nothing after it. I tried

swOut.WriteLine("{0,10:###0.}", var)

But the output is a whole number

886
913
941

[Code].....

View 1 Replies

Terminating A Windows Form Application?

Dec 18, 2009

What is the proper way to terminate a Windows Form application while it is just executing in the MyApplication_Startup routine?I have an application that looks for a database file upon startup. If it does not find it I prompt the user and ask if they wish to locate the file or not. If they choose not to locate the file I want to just terminate the application. Currently i just execute the "End" statement, but that does not seem like the proper way to terminate a program.

View 2 Replies

VS 2008 Terminating A Process Handle

Aug 24, 2009

I have a DLL that copies an Access database, opens it, reads it, and then closes it. The second time through it is unable to copy the Access DB because the EXE has an open handle to it. The EXE does not reference the Access DB at all, it just has the open handle because it calls my DLL. After I close the DB, I would like to terminate the EXE's handle to the Acess DB. BTS - I wrote the DLL and it is my Access DB. Another company wrote the EXE and I can not make any changes to it.

[Code]...

View 6 Replies

Which Of The VB Controls Is Best Suited To Show Images In A Strip Like Fashion From An Image Array

May 24, 2009

Which of the VB controls is best suited to show images in a strip like fashion from an Image Array?I have an Image Array. I would like to display the images in the array to the end-user in a control.The control should should apear like a scrollabel list. I guess something like silverlight does.When the user sees and selects an image he/she wants to view, it is selected by clicking on the thumbnail and appears in a picturebox.

View 1 Replies

Remotely Terminating Program To Update New Version

Nov 8, 2011

I have several programs written in VB2008 on a network shared drive. Multiple PC's which have access to this drive run the programs. The problem is when I want to upgrade the program or a file/picture with changes, either I cannot overwrite the .exe file because someone is running it, or for example, a background picture on an open form is loaded and then I cannot change the picture on the server. I thought of placing a timing loop in the programs to frequently check a file on the server, which when I need to make a change, I can fill with an appropriate trigger word (like "exit") that would have the program terminate and be unable to restart until I change the file to "OK", but this seems rather crude. I assume there's a better and more elegant method.

View 2 Replies

V.NET Winform Program Terminating Without Any Valid Reason On End Sub?

Oct 7, 2011

I'm using agsXMPP in my .NET project (WinForms).I have the following Code block, this is executed whenever a message is received from any client.Now whenever a message is received, this block executes and the program terminates..Has this something to do with threads? (I've heard that agsXMPP encapsulates a thread on which it works)

Private Sub messageReceived(ByVal sender As Object, ByVal msg As protocol.client.Message)
Dim chatMessage() As String
Static Dim Hi_ed As Integer = 0[code].........

View 2 Replies

Objects - Display Some Test Extra Textboxes In A Dimmed / Transparent Type Of Fashion

Feb 9, 2010

I have a form that displays data. What I would like to have is a button that when pressed will display some test extran textboxes in a dimmed/transparent type of fashion. I can get that using another form, but would like to do it without the second form.

View 1 Replies

Close Only The Main Form In 2010 Without Terminating The Application?

May 7, 2011

I have a login form which I need to close without the entire application being terminated. I tried using Me.Close() , Me.Hide() as well. The login form is used as the main form as well.

View 2 Replies

Terminate - Terminating An Application Programmatically Using A File Path

Sep 9, 2009

I want to terminate an application using the full file path via vb.net, yet I could not find it under Process. I was hoping for an easy Process.Stop(filepath), like with Process.Start,

View 2 Replies

Keep Form On Top Of Another Form In Modal Fashion, But Continue Execution?

Apr 18, 2012

I have a form in a vb.net windows form application called PolicyRefreshStatus.vb that has a ProgressBar control on it. From the main form called EditPolicy.vb I need to show PolicyRefreshStatus.vb over top of EditPolicy.vb - but the way things are wired I'm controlling the the ProgressBar and it's steps from logic inside EditPolicy.vbIf I display the PolicyRefreshStatus.vb bar using the .show() method things work fine.The problem is if the user clicks back on the main form then PolicyRefreshStatus.vb losses focus. If I show PolicyRefreshStatus.vb as a modal form using .ShowDialog() then execution halts in EditPolicy.vb after the .ShowDialog() statement.

so for example in the code:
mPolicyRefreshStatus = New PolicyRefreshStatus
mPolicyRefreshStatus.pbMax = mPolicy.ClaimsUpdateMax

[code]....

View 2 Replies

.net - ASP.NET Two Threads, One Result?

Sep 14, 2011

I need to run TWO Threads in a web application, .NET. 3.5 Both methods MakeRedCars and MakeBlueCars need to run at the same time as both take 5 seconds. I have tried many example codes with very bad results. I dont need anymore than 2 threads. The main issue I am having is knowing how to wait till they are finished and also how to store the results from each.Each of the Methods do different things, one is a web request, one is a sql call.

Both methods return a list of(cars) for example do:

carList.addrange(MakeRedCars())
carList.addrange(MakeBlueCars())
for each car in carlist<br>
response.write(car.colour + "<r>")
next

I have implemented the answered below and with empty objects all works well, as soon as you hook in a database call that returns the data/objects studio does a JIT and crashes.

View 5 Replies

.net - How Many Threads Can Run Concurrently

Jan 28, 2011

I can only run "so many" threads concurretnly, a notion which I have seen elsewhere.As a threading novoice, how can I determine the maximum number of threads to use? Or is this a "how long is a piece of string" question? What does it depends on? Hardware config or what?

View 4 Replies

.net - Using GDI+ With Multiple Threads?

Apr 18, 2010

it would be best if I just copy and pasted the code (it's very trivial).

Private Sub Main() Handles MyBase.Shown
timer.Interval = 10
timer.Enabled = True
End Sub

[code]....

An exception, "The object is currently in use elsewhere", is raised during the tick event.

View 1 Replies

.NET Scheduling Threads?

Oct 25, 2010

I am having an issue where I need to implement a type of thread scheduling... I'm looking to implement a list of tasks, each with a set time that they need to execute, and after the time is up they will execute the respective code that goes with that task. I would use a timer based solution, however, I don't think that it would be very efficient. There will be a very large list of tasks, some of which need to be executed within seconds of being placed in the list.

View 1 Replies

Best List For 2 Threads?

Jun 10, 2010

I have 2 thread.One that put some data inside a list?the second that take out these data from the same list.what is the best "list" that allows one thread to put something inside and another one that take stuff out>

View 1 Replies

Get Rid Of Background Threads?

Nov 7, 2010

My application generates some background threads to perform some slow jobs (a cycle of ask for a long process to a server - wait - download the result).

View 5 Replies

How To Know All Threads Are Cancelled

Feb 25, 2009

I'm having a bit of an issue killing threads off and resetting my form. After starting the threads, everything runs fine. When I want to cancel the threads, the threads are all killed off "properly" using the Abortable Thread Pool, but how do I know that all the threads are dead? I've tried using both GetAvailableThreads and GetMinThreads compared against the thread count that should be running if they're all killed off, but I can't seem to get it to work. The only time I can get the GetAvailableThreads to return the "correct" number is if I freeze one thread and kill off the rest.

View 7 Replies

How To Merge 2 Threads

May 28, 2010

I have a GUI that is running for a form, let's call it Class xWindow. It has finished processing data and is simply waiting for the user to press a button, i.e. the main thread has nothing to do. Just before it finished processing, it kicked started something that has a callback function which occurs in a new thread (e.g. a system timer or a Bonjour callback to say that a service has been found on a port). This callback occurs within the xWindow class.

[Code]....

View 10 Replies

Keep Adding New Threads As Old Ones End?

Dec 22, 2010

Suppose I have created 70 "rule-finder" objects, and I want to run each one on data.This is a time-consuming process.The new computers with the I7 chip can run 7 processes in parallel, and so I was thinking of running 7 threads at a time. Asone thread ends, I would add another, until all 70 objects are used. When the last rule-finder has completed, I would resume the main course of the program.

View 5 Replies

Let Two Threads Communicate With Each Other

Jun 1, 2009

how can I let two threads communicate with each other by using VB.net?

View 3 Replies

Progress 'bar' Using Threads

Jan 25, 2010

I currently have a program that runs several "intense" queries. I added a textbox and presented status updates when a query was starting, eding and how many were left. This would suite my need, but the textbox doesn't actually display anything until all the queries are finished. It then displays all the updates at once. I'm assuming updating the textbox in another thread would solve this issue, and that is where I am lost. How can I use a thread that receives a message from the main form running the query and have it display it in the textbox?

View 4 Replies

Ran Into Some Threads Tlaking About XML?

Feb 25, 2009

I'm making a Tabbed Web Browser, and I need favorites to add to this web browser, I was searching this forum for answers on how to do it and I ran into some threads tlaking about XML and how they are easily controlled, yet a little more complex. How do I do this? Where do I start?

View 2 Replies

Threads In These Two Methods Different?

Jan 23, 2011

Take a look at the code below. Here I create a thread, set its name, and start it:

Private Sub fileCreated(sender As Object, e As FileSystemEventArgs)
Dim processFileThread As Thread = New Thread(AddressOf fileCreatedHelper)
processFileThread.Name = e.FullPath
processFileThread.Start()
End Sub

This is the sub that is the thread: Private Sub fileCreatedHelper()

[Code]...

View 2 Replies

Threads In Windows App?

Aug 17, 2011

I have a threading problem when it comes to updating the gui from the thread.

In my main function I have the following:

Private Sub StartThreads(Optional OrgName As String = "")

Dim blnMonitorEntered As Boolean = False

[Code]...

View 6 Replies







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