VB - Multithreading With Synclock - Threads With Different Sessions Run Trylock Simultaneously

Jan 31, 2011

i have some test code which i run at every load of a page in my asp.net website [Code] the "dotrace" simply add a record to a log table in the db. now the right result would be that i should have the entries in the db in order "entered","exiting","exited" but actually when i look in the db i see first 2 "entered" then 2 "exiting" etc. meaning that the multi-threading is working ok, but not the synclock. is that correct?

and how can this be fixed? the real code will be adding records to the db and might be called from several pages of different sessions, but the same code must not run twice concurrently. if i open multiple pages at once, they still clash some times. but if i'm correct, the issue is now not with the synclock as much as with the httpruntime.cache, because when using a standard property, on one page, the code works 100%. so how can i make sure that 2 threads, even from totally different sessions never run the trylock simultaneously?

View 1 Replies


ADVERTISEMENT

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

[2005] SyncLock And Multithreading - Public Class Utilities With A Many Shared Functions

Feb 11, 2009

I am trying to get a handle on SyncLock and multithreading, but I am having some trouble wrapping my head around exactly how it should be implemented. I have a Public Class Utilities with a many Shared Functions. I want to make sure that each function can only be executed when there are no other concurrent calls to the same function. So If I have 2 functions, A and B in a Public Class Utilities, what is the syntax so that a function "locks" while it is being executed, preventing any subsequent calls until the "locking" thread has completed?

CODE

Public Class Utilities

Public Shared Function A (ByRef i As Integer) As Integer

[CODE].............................

I know I need to wrap the statements of execution in a SyncLock block, but I am unsure of the scope of the parameter used with SyncLock...is it private to the function, class, etc? Can the same object be used to lock both functions if they are independent?

View 36 Replies

Run Multiple Funcations Simultaneously Using Multithreading Concept?

Jun 6, 2012

How to run multiple funcations simultaneously using multithreading concept?

Actually i am making a software which has backend tool as MS ACCESS. it has 15000+ records in database and i need to display that records as my software loads..but it is much time consunable and sometimes it even goes out of time exception

View 7 Replies

Synclock Doesn't Prevent Sharing Errors When Multiple Threads Access Same File

Apr 14, 2010

I am using Synclock to prevent multiple threads from logging text messages to the same file at the same time, but this doesn't seem to work:I get frequent sharing errors on the logfile, within the synclock block.The Synclock is using the variable holding the filename, because it exists all the time and because it is always the same object, whatever class instance or thread I'm in.[code]Despite using Synclock and a Using block around the code, I keep getting this error in the sw.WriteLine(Msg) line:System.IO.IOException: The process cannot access the file '(filename)' because it is being used by another process.Should I use some other type of object than a string to synchronize on?I cannot use a user interface object (button or so) because it is a windows service project.It was written and compiled in Visual Studio 2008, but targeting the 2.0 framework because it has to be able to run on some old Win2000 machines.

View 12 Replies

Threads - Check About 30 Links Simultaneously Using HttpWebRequest?

Dec 30, 2009

check about 30 links simultaneously using HttpWebRequest?

View 1 Replies

Add Two Numbers Up Using Threads Or Multithreading?

Jun 16, 2012

My question is to add two numbers up using threads or multithreading. Here is what I have:

Module Module1
Sub ThreadA()
Dim I As Integer[code].....

Is there a way I can use this somehow to add two numbers up?

View 1 Replies

VS 2005 - Multithreading - How Are Threads Accessing The Sub

Oct 15, 2010

I have 10 threads each using the same sub to do work. This sub is calling a function to save the results. How are the threads accessing the sub? Is each one getting a fresh copy of the sub to do its thing or are they using the same piece of code and need to wait for each other to finish processing? I don't get any hits when searching for such a specific scenario. I am wondering because it is about using sockets (usually lightweight stuff) to retrieve a resource and the cpu is working at 100% all the time. Still it is very fast, 900 internet queries finish in about 3 minutes.

View 4 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

Multithreading - Speed Up Loop Through Additional Threads?

Dec 27, 2010

I have problem with multithreading.

For:

Code:

and multithreading to loop for:

Code:

How can I speed up this loop through additional threads?

I tried:

Code:

How can I do?

View 10 Replies

.net - Multithreading Function To Implement Threads Fetching From A List Of Urls To Parse Content?

Feb 2, 2010

I have the following multithreading function to implement threads fetching from a list of urls to parse content. The code was suggested by a user and I just want to know if this is an efficient way of implementing what I need to do. I am running the code now and getting errors on all functions that worked fine doing single thread.for example now for the list that I use to check visited urls; I am getting the 'argumentoutofrangeexception - capacity was less than the current size'/Does everything now need to be synchronized?

Dim startwatch As New Stopwatch
Dim elapsedTime As Long = 0
Dim urlCompleteList As String = String.Empty

[code]...

View 2 Replies

SyncLock / Multithreading - Child Thread Reading The Values Of _do At The Same Time As Another Child Thread Is Reading The Values

Nov 13, 2009

I have a dictionary object (let's call it _do) I am using to cache some values for use in a multi-threaded program. I have a single controlling parent thread, with a timer function _doTimer() which can kick off child threads with a new instance of class MyThreadObject in each. My parent thread has _do as a property and with each time _doTimer() gets called, it may or may not repopulate _do depending on cacheflag settings. I pass a reference to _do to each instance of MyThreadObject and those threads at some point read the values of _do but DO NOT write to it.

What I want is to ensure that the child threads do not try and read _do whilst the parent thread is writing to it. Same thing but very slightly different -> I also don't want the parent thread to write to _do whilst the child threads are reading from it. However there is no problem with 1 child thread reading the values of _do at the same time as another child thread is reading the values - so ideally I do not want each child thread to completely lock out read access, only locking out Write access.. The code is roughly like this:

[Code]....

View 3 Replies

Multithreading - Me.Invoke Doesn't "Invoke" - Threads Stall On Invoke Statement

Mar 16, 2010

I've got the following code:

[code]...

The problem is that, when I call the "SetStatusBarText" sub from another thread, InvokeRequired is True (as it should be), but then my threads stall on the Me.Invoke statement - pausing execution shows them all just sitting there, not actually invoking anything.

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

Using SyncLock And Monitor Together?

Sep 15, 2010

I was just wondering if mixing SyncLock blocks and Monitor.Enter/Exit statements is dangerous. I know SyncLock uses Monitor and a Try block in the background, but are there any problems with using the two together for thread synchronization?

View 1 Replies

Access Sessions In Asp.net Handler ?

Apr 13, 2012

I am trying to upload images using generic handler as shown below and I have a normal aspx page where I am showing all the uploaded images after uploading.Everything is working fine.

CODE:

Now I want to add a session variable by generating a random string and add the uploaded images to the newly created random string.

1.I have seen this Question on SO to use System.Web.SessionState.IRequiresSessionState for sessions and how do I create a folder with that and add my images to that folder after doing that how do I access this session variable in my normal aspx page.

2.(Or) the better way is create session variable in aspx page and pass that to handler?If so how can I do that?

3 .I am trying to find the control from my handler.Is that possible?If anyone knows how to get this then also my problem will get resolved so that I am trying to create a session from m aspx page.

View 1 Replies

Secure User Sessions In ASP .net Using VB?

Oct 5, 2009

procedure to create multiple secure user sessions in ASP.net.

View 1 Replies

Shared Methods In ASP.NET Sessions

Feb 25, 2011

As a followup to the previous question I have asked "ASP.Net Architecture Specific to Shared/Static functions" I am still struggling to understand the implications of using shared methods in ASP.NET.

So for example let us take the following code.[code...]

View 3 Replies

.net - How To SyncLock A Shared Integer

May 28, 2012

I am pretty new to multi-threading in general and I would like to know how can I lock a shared integer variable to not be accessed by other threads while it is read/updated by an other thread.When I try do do SyncLock myInteger, I get that error : Error 6 'SyncLock' operand cannot be of type 'Integer' because 'Integer' is not a reference type.

Here a simplified example of what I mean

Private Shared myInteger As Integer
Private Sub MySub()
SyncLock myInteger ' This does not work
' read/write a new value to myInteger
End SyncLock
End Sub

MySub is called by multiple instances of the class, and running in multiple threads?

View 1 Replies

.net - SyncLock On Null Object

Mar 25, 2011

Is there simple way to SyncLock an object that can be null? And before you ask for it, yes, I know that it isn't logical to perform a SyncLock on a null variable. However, that would simplify my code because right now, I have no choice but to perform a null check all over the place before calling a SyncLock.

[Code]...

View 3 Replies

.NET SyncLock Order Deadlock?

Sep 7, 2010

If I have two Synclocks

synclock a
synclock b
end synclock

[code].....

View 1 Replies

Invoke Within SyncLock Causes Deadlock

Apr 13, 2011

I was wondering if this is known / expected behavior. By design?Is it documented somewhere?

My 'real' code does need something to keep one thread from accessing a listview while another is busy clearing and refreshing the Items collection, so it's not as easy as omitting the synclock section in the example below (The SyncLock in my case is on the ListView).

This code, which can be pasted over a new empty form's user code class, deadlocks during the Invoke call. It doesn't reach the entry point of SetText (setting a brakpoint there, the deadlock occurs before the breakpoint is hit).[cod]e...

View 4 Replies

Safe To Use A Synclock On The Serialport?

Aug 3, 2009

I have an application that requires several threads, otherwise the main UI thread would end up frozen.i am after a little advice as i have not really don alot of threaded applications.

First Question;

I have a thread which handles data coming in from the serial port( this wil become much more complicated), is it safe to use a synclock on the serialport object : -

[code]...

View 3 Replies

SyncLock On Write - Read - Or Both?

Jan 7, 2011

Suppose I have a byte array, Private Data as Byte(). This array is private within a class. The class provides public functions for reading and writing to Data. This class can be accessed by multiple threads, so I want to avoid a situation where reading from it and writing from it don't happen at the same time.

For now, I am using SyncLock to avoid issues. Can I put SyncLock Data in just the write functions, or does it need to be in the read functions? Or, both? I don't have a specific code example in mind. I am just curious if there is any benefit to locking for both read and write functions if the writing functions' SyncLock will make writing have exclusive access to it in the first place.

View 2 Replies

VS 2008 SyncLock A DataTable?

Oct 24, 2009

I'm trying to SyncLock my DataTable, to avoid problems with multithreading and stuff. But it doesn't seems to work. I'm trying to lock a DataTable wich is acceseed inside a nested for-loop:

vb.net
SyncLock radiolopere
For Each row As DataRowView In tableview

[code].....

View 4 Replies

Enable Multiple Sessions For WebBrowser?

Dec 6, 2011

Even after numerous attempts, im unable to set different sessions for multiple webbrowsers (in tabs ) hosted on the same windows form.

So far, i have tried the following methods (and failed)Created a new form for each session (The WebBrowsers share the session)Used HttpWebRequest,HttpWebResponse to get and set separate sessions for each webbrowser ( Couldn't implement this properly)Could someone please point me out to a proper channel on how to implement this ?

View 6 Replies

IDE :: Keep The Size Of The Properties Window Across Sessions?

Apr 10, 2009

When I start working on a Project I like to change the size of the Properties Window. (I like to make it taller than it is by default). But each time I start a new Project the Properties Window goes back to the original shape/location. Is there a way that I can customize the layout of that window so that the shape is retained across sessions?

View 6 Replies

VS 2008 Multiple Sessions - Different Web Browsers

Sep 10, 2009

I've thought long and hard on how to do this. Since I'm posting here, you see I haven't figured it out. I've found out how to login to a website with GetElementById, but I have another problem. I need to login with multiple web browsers. But when I login on the second, I can't because the session/cookie is already there. I thought usnig a proxy would work, but that just applies to both web browsers. Using the example below, would it be possible to apply this to only one web browser? Or make separate sessions for each web browser control?

[Code]...

View 2 Replies

VS 2010 Different Applications Share Same Sessions?

Oct 19, 2010

just wanted to ask if it is possible to have different applications sharing the same session (i.e. database session)... i'm planning on creating a web-based application and a form-based application using asp.net for web and vb.net for forms but i need to have them share sessions since some global variables will be session based and also authentication to one application should also authenticate on the other.

View 2 Replies

VS 2010 Passing Objects And Sessions?

Aug 21, 2011

I was wondering if someone could tell me if this is "bad practice" or is a perfectly acceptable way to pass an object to another form.I've cut out a lot of the code to summarise what im asking.

[Code]...

Dim myRetrievedObject as myObject = Module1.returnSavedObject()Is this a acceptable way of passing an object between forms or is it a completely bad idea?Ideally i would like to be able to "add" further objects to the initially created object in Form1 but then on reloading of Form1 , retrieve the new version of myObject with the newly added objects within the myObject class.My initial thinking is this creates an almost session like state for the initial object. So you can use the same object over all 3 forms or more and just simply add to it like a shopping cart type of functionality.

View 10 Replies







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