Probably not - IIRC none of the .NET Collections are intrinsically thread safe, and they should all be locked.
Either use the .NET Queue[^] with a lock or homebrew a safe version. If you are just using a single in-feed and a single out-feed, you don't need to use locking if you write it correctly.
One way is to use an array, with two indexes - input and output. If insert only affects the input, and remove only affects the output, the only time they need to both be checked is for a full/empty test, which shouldn't need a lock - it would if you used more than one input source, or more than one remover.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
However, IIRC there's the potential for a delayed garbage collection - the queue keeps a reference to the object even after it's dequeued until it's been overwritten in the queue's buffer. This becomes more of an issue with a large-capacity queue. Our workaround was to use the Mono implementation of the ConcurrentQueue instead (it doesn't have this problem).
The shout of progress is not "Eureka!" it's "Strange... that's not what i expected". - peterchen
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
yes this was my intention to have to indexes one for read, one for write, and because it is in a Handlerfunction it should be executed very fast so I will use a vector - as the circular list (or Buffer).
I will try this solution first, after the other with the Thread safe collections.
probably I need some kind of lightweight lock, bacause the call to the Handler can come realy fast and mess up with my array index, which is already done in ConcurrentQueue<t> Class. Even if I use a state bit on every element the index could be messed up by another call just before it is used.
I have been wondering how it is implemented. Would be possible this class: ConcurrentQueue<t> Class to e implemented using just Interlock class witout any SpinWait or while loops?
Well, how "appropriate" the answer is depends entirely on what the hell you mean by "create monthly calender".
That could mean anything! Are you trying to come up with a control that lets you input a date, a data range over months, something to display an entire month, storing data based on some month requirement, ... ??? WHAT?
Shortcuts generally work whichever control on a form has focus, unless the control explicitly steals that character (i.e. text boxes with Ctrl+C/X/Z/V). I think you need to put a shortcut handler on every form, though, if you want app-wide ones.
Yes, it is, but you will have to go on treacherous ground to do so (needs some unmanaged code). Take a look at keyboard hooks, more specifically RegisterHotKey and UnregisterHotKey, both from user32.dll.
Google it further, there are a lot of threads detailing how this can be achieved, for instance here[^], or here[^]
Full-fledged Java/.NET lover, full-fledged PHP hater. Full-fledged Google/Microsoft lover, full-fledged Apple hater. Full-fledged Skype lover, full-fledged YM hater.
My need will be to make an hrttprequest in asynchronous mode. To not let the user wait for a response that can be processed in backround. First I was thinking to use a BackroundWorker, then I see that begingetresponse example But it react exacly as the BeginResponse : when I step over it wait a few seconds to get the response. So maybe I misunderstand something but I don't see any advantage of this method ??
BeginGetResponse will execute the method in the AsyncCallBack asynchronously. If you do like in the MSDN example then it will wait for that asynchronous operation to finish this is the code that will cause it to wait and also implements a timeout method so if the asynchronous operation takes to long it will end the asynchronous operation.
// this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted
ThreadPool.RegisterWaitForSingleObject (result.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), myHttpWebRequest, DefaultTimeout, true);
// The response came in the allowed time. The work processing will happen in the
// callback function.
I'm thinking you must have missed something initially, BeginGetResponse should return immedialtely. The only reason I would see to run that in a dedicated thread is if you want to worry about a timeout or want to ensure the asynchronous method completes like the example, as the method will block waiting for the ManualResetEvent to be set. Using the ManualResetEvent is for situations where you can't process the next step until that process has completed.
Some more investigation turns out this is a known issue. Apparently it blocks during the name resolution so does not return immediately as you would think. Sorry, I should have looked into it a little more before replying.
I have two databases(SQlserver and MS Access) with same schemas (same tables). SQL server database has data but Access has no data (blank database).
My goal : when user enters a ClientId and click insert button then I need to retrive that single record from all tables in sql server database and insert into tables in MS Access Database.
Achieved: i retrived from all tables in sql server databases with client id and stored the data in Dataset.
Problem: Insert into Access tables????
i have table array and i am looping thru all tables in array and trying to insert data from above dataset into Ms Access dynamically.
Can you suggest how insert into Access for all tables dynamically in loop . i cannot wrie insert statement for each table. i need one which is generic for every table so that i will pass parametrs. Its not a bulk insert, its single record push into multiple tables.
-------This is My code-------------------------------------------------------
If you have two datasets 1) from MSSQL 2) from MS Access and all column names and table names match you should be able to iterate the datatables in the datasets and us importrow method to copy a row from one to the other and then use data adapter to execute update command and should use the assigned insert/update commands assigned to the data adapter to populate the data into the database.
You have no reason to have all the data in memory at once so use a DataReader, not a DataSet.
0) ExecuteReader on the SELECT command 1) Iterate the DataReader's columns to create the INSERT command and its parameters 2) Read from the DataReader 3) Set the INSERT command's parameter values 4) ExecuteNonQuery 5) Repeat from 2 as necessary
You should also use a try/catch and a transaction.
There are various methods to do so, some more appropriate than others depending on what your application is doing.
Form2 could expose properties that your Form1 code sets, or you could use delegates to pass data to a method on Form2, or both forms could be using the same data object where Form1 sets some values in this object and Form2 picks it up by some notification method the data object exposes, ...
Please describe in more detail exactly what you mean by "transfer data" here.
Re the comments by esteemed colleagues, Dave Kreskowiak, and Abhinav S: I don't know why, but every time I see someone advocate using delegates, in this type of context, without also using the words "and events," a kitten inside my mind dies I'll try to get over that !
"Everything we call real is made of things that cannot be regarded as real." Niels Bohr
You're going to have to explain exactly what you mean by "dot matrix display". Are you talking about an LED driven piece of hardware? Are you talking about some control you drop of your form? Are you talking about some LED display contorl you're creating??
Without knowing this, it's pretty much impossible to tell you "how to scroll" on this display.
I already know this stuff, and, frankly, would NEVER use a parallel port to control anything as it's too easy to blow the port up. I'd use hardware dedicated to the purpose like something from Phidgets or a Netduino or Arduino.
Since the original poster never specified what they were using as an "LED display" the question is unanswerable. I really don't feel like going through every possibility of scrolling an image on every type of "LED display" as it would take a small book to describe them all.
'System.Xml.XmlNodeList' does not contain a definition for 'SelectNodes' and no extension method 'SelectNodes' accepting a first argument of type 'System.Xml.XmlNodeList' could be found (are you missing a using directive or an assembly reference?)
Thank you for your reply. I am getting this error. But no problem I got my solution