Search Results

Search found 31774 results on 1271 pages for 'chris go'.

Page 34/1271 | < Previous Page | 30 31 32 33 34 35 36 37 38 39 40 41  | Next Page >

  • SQL SERVER – Simple Example of Snapshot Isolation – Reduce the Blocking Transactions

    - by pinaldave
    To learn any technology and move to a more advanced level, it is very important to understand the fundamentals of the subject first. Today, we will be talking about something which has been quite introduced a long time ago but not properly explored when it comes to the isolation level. Snapshot Isolation was introduced in SQL Server in 2005. However, the reality is that there are still many software shops which are using the SQL Server 2000, and therefore cannot be able to maintain the Snapshot Isolation. Many software shops have upgraded to the later version of the SQL Server, but their respective developers have not spend enough time to upgrade themselves with the latest technology. “It works!” is a very common answer of many when they are asked about utilizing the new technology, instead of backward compatibility commands. In one of the recent consultation project, I had same experience when developers have “heard about it” but have no idea about snapshot isolation. They were thinking it is the same as Snapshot Replication – which is plain wrong. This is the same demo I am including here which I have created for them. In Snapshot Isolation, the updated row versions for each transaction are maintained in TempDB. Once a transaction has begun, it ignores all the newer rows inserted or updated in the table. Let us examine this example which shows the simple demonstration. This transaction works on optimistic concurrency model. Since reading a certain transaction does not block writing transaction, it also does not block the reading transaction, which reduced the blocking. First, enable database to work with Snapshot Isolation. Additionally, check the existing values in the table from HumanResources.Shift. ALTER DATABASE AdventureWorks SET ALLOW_SNAPSHOT_ISOLATION ON GO SELECT ModifiedDate FROM HumanResources.Shift GO Now, we will need two different sessions to prove this example. First Session: Set Transaction level isolation to snapshot and begin the transaction. Update the column “ModifiedDate” to today’s date. -- Session 1 SET TRANSACTION ISOLATION LEVEL SNAPSHOT BEGIN TRAN UPDATE HumanResources.Shift SET ModifiedDate = GETDATE() GO Please note that we have not yet been committed to the transaction. Now, open the second session and run the following “SELECT” statement. Then, check the values of the table. Please pay attention on setting the Isolation level for the second one as “Snapshot” at the same time when we already start the transaction using BEGIN TRAN. -- Session 2 SET TRANSACTION ISOLATION LEVEL SNAPSHOT BEGIN TRAN SELECT ModifiedDate FROM HumanResources.Shift GO You will notice that the values in the table are still original values. They have not been modified yet. Once again, go back to session 1 and begin the transaction. -- Session 1 COMMIT After that, go back to Session 2 and see the values of the table. -- Session 2 SELECT ModifiedDate FROM HumanResources.Shift GO You will notice that the values are yet not changed and they are still the same old values which were there right in the beginning of the session. Now, let us commit the transaction in the session 2. Once committed, run the same SELECT statement once more and see what the result is. -- Session 2 COMMIT SELECT ModifiedDate FROM HumanResources.Shift GO You will notice that it now reflects the new updated value. I hope that this example is clear enough as it would give you good idea how the Snapshot Isolation level works. There is much more to write about an extra level, READ_COMMITTED_SNAPSHOT, which we will be discussing in another post soon. If you wish to use this transaction’s Isolation level in your production database, I would appreciate your comments about their performance on your servers. I have included here the complete script used in this example for your quick reference. ALTER DATABASE AdventureWorks SET ALLOW_SNAPSHOT_ISOLATION ON GO SELECT ModifiedDate FROM HumanResources.Shift GO -- Session 1 SET TRANSACTION ISOLATION LEVEL SNAPSHOT BEGIN TRAN UPDATE HumanResources.Shift SET ModifiedDate = GETDATE() GO -- Session 2 SET TRANSACTION ISOLATION LEVEL SNAPSHOT BEGIN TRAN SELECT ModifiedDate FROM HumanResources.Shift GO -- Session 1 COMMIT -- Session 2 SELECT ModifiedDate FROM HumanResources.Shift GO -- Session 2 COMMIT SELECT ModifiedDate FROM HumanResources.Shift GO Reference: Pinal Dave (http://blog.sqlauthority.com) Filed under: Pinal Dave, SQL, SQL Authority, SQL Performance, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology Tagged: Transaction Isolation

    Read the article

  • SQL SERVER – Simple Example of Snapshot Isolation – Reduce the Blocking Transactions

    - by pinaldave
    To learn any technology and move to a more advanced level, it is very important to understand the fundamentals of the subject first. Today, we will be talking about something which has been quite introduced a long time ago but not properly explored when it comes to the isolation level. Snapshot Isolation was introduced in SQL Server in 2005. However, the reality is that there are still many software shops which are using the SQL Server 2000, and therefore cannot be able to maintain the Snapshot Isolation. Many software shops have upgraded to the later version of the SQL Server, but their respective developers have not spend enough time to upgrade themselves with the latest technology. “It works!” is a very common answer of many when they are asked about utilizing the new technology, instead of backward compatibility commands. In one of the recent consultation project, I had same experience when developers have “heard about it” but have no idea about snapshot isolation. They were thinking it is the same as Snapshot Replication – which is plain wrong. This is the same demo I am including here which I have created for them. In Snapshot Isolation, the updated row versions for each transaction are maintained in TempDB. Once a transaction has begun, it ignores all the newer rows inserted or updated in the table. Let us examine this example which shows the simple demonstration. This transaction works on optimistic concurrency model. Since reading a certain transaction does not block writing transaction, it also does not block the reading transaction, which reduced the blocking. First, enable database to work with Snapshot Isolation. Additionally, check the existing values in the table from HumanResources.Shift. ALTER DATABASE AdventureWorks SET ALLOW_SNAPSHOT_ISOLATION ON GO SELECT ModifiedDate FROM HumanResources.Shift GO Now, we will need two different sessions to prove this example. First Session: Set Transaction level isolation to snapshot and begin the transaction. Update the column “ModifiedDate” to today’s date. -- Session 1 SET TRANSACTION ISOLATION LEVEL SNAPSHOT BEGIN TRAN UPDATE HumanResources.Shift SET ModifiedDate = GETDATE() GO Please note that we have not yet been committed to the transaction. Now, open the second session and run the following “SELECT” statement. Then, check the values of the table. Please pay attention on setting the Isolation level for the second one as “Snapshot” at the same time when we already start the transaction using BEGIN TRAN. -- Session 2 SET TRANSACTION ISOLATION LEVEL SNAPSHOT BEGIN TRAN SELECT ModifiedDate FROM HumanResources.Shift GO You will notice that the values in the table are still original values. They have not been modified yet. Once again, go back to session 1 and begin the transaction. -- Session 1 COMMIT After that, go back to Session 2 and see the values of the table. -- Session 2 SELECT ModifiedDate FROM HumanResources.Shift GO You will notice that the values are yet not changed and they are still the same old values which were there right in the beginning of the session. Now, let us commit the transaction in the session 2. Once committed, run the same SELECT statement once more and see what the result is. -- Session 2 COMMIT SELECT ModifiedDate FROM HumanResources.Shift GO You will notice that it now reflects the new updated value. I hope that this example is clear enough as it would give you good idea how the Snapshot Isolation level works. There is much more to write about an extra level, READ_COMMITTED_SNAPSHOT, which we will be discussing in another post soon. If you wish to use this transaction’s Isolation level in your production database, I would appreciate your comments about their performance on your servers. I have included here the complete script used in this example for your quick reference. ALTER DATABASE AdventureWorks SET ALLOW_SNAPSHOT_ISOLATION ON GO SELECT ModifiedDate FROM HumanResources.Shift GO -- Session 1 SET TRANSACTION ISOLATION LEVEL SNAPSHOT BEGIN TRAN UPDATE HumanResources.Shift SET ModifiedDate = GETDATE() GO -- Session 2 SET TRANSACTION ISOLATION LEVEL SNAPSHOT BEGIN TRAN SELECT ModifiedDate FROM HumanResources.Shift GO -- Session 1 COMMIT -- Session 2 SELECT ModifiedDate FROM HumanResources.Shift GO -- Session 2 COMMIT SELECT ModifiedDate FROM HumanResources.Shift GO Reference: Pinal Dave (http://blog.sqlauthority.com) Filed under: Pinal Dave, SQL, SQL Authority, SQL Performance, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology Tagged: Transaction Isolation

    Read the article

  • Initializing SD card in SPI issues

    - by Sembazuru
    Sorry for the length of this question, but I thought it best to show as much detail to fend of questions asking if I had done A when I had already done A... ;-) I've had a look at the "micro-SD card initialization using SPI interface" thread and didn't see any answers that matched my issue (i.e. things I haven't already tried). I have a similar issue where I'm trying to access a SD card through a micro-controller's SPI interface (specifically an HC908). I've tried following the flow charts in the Physical Layer Simplified Specification v2.00 and it seems to initialize correctly on Transcend 1GB & 2GB and an AE&C 1GB card. But I'm having problems on 3 other random cards from my stash of old cards that I've used on my camera. My code is all HC908 assembler. I scoped out the SPI clock line and during initialization it's running about 350kHz (the only speed multiplier that the HC908 supplies at my low MCU clock speed that falls within the 100-400kHz window). Here are the results of the three cards that aren't completing my initialization routine (all done consecutively w/o changing any code or timing parameters): Canon 16Meg card (labeled as SD): Set card select high Send 80 SPI clock cycles (done by writing 0xFF 10 times) Set card select low Send CMD0 [0x400000000095] and Loop up to 8 times waiting for high bit on response to go low R1 = 0x01 (indicates idle) Send CMD8 [0x48000001AA87] and Loop up to 8 times waiting for high bit on response to go low R1 = 0x05 (idle and illegal command) Because illegal command set local flag to indicate v1 or MMC card Send CMD58 [0x7A00000000FD] and Loop up to 8 times waiting for high bit on response to go low R1 = 0x05 (idle and illegal command) because illegal command branch to error routine Send CMD13 [0x4D000000000D] (show status buffer) and Loop up to 8 times waiting for high bit on response to go low R1= 0x05 (idle and illegal command) Is the illegal command flag stuck? Should I be doing something after CMD8 to clear that flag? SanDisk UltraII 256Meg Set card select high Send 80 SPI clock cycles (done by writing 0xFF 10 times) Set card select low Send CMD0 [0x400000000095] and Loop up to 8 times waiting for high bit on response to go low R1 = 0x01 (idle) Send CMD8 [0x48000001AA87] and Loop up to 8 times waiting for high bit on response to go low R1 = 0x05 (idle and illegal command) Because illegal command set local flag to indicate v1 or MMC card Send CMD58 [0x7A00000000FD] and Loop up to 8 times waiting for high bit on response to go low R1 = 0x01 (idle) Send 0xFF 4 times to read OCR OCR = 0xFFFFFFFF Send CMD55 [0x770000000065] (1st part of ACMD41) and Loop up to 8 times waiting for high bit on response to go low R1 = 0x01 (idle) Send CMD41 [0x6900000000E5] (2nd part of ACMD41) and Loop up to 8 times waiting for high bit on response to go low R1 = 0x05 (idle and illegal command) Because illegal command, assume card is MMC Send CMD1 [0x4100000000F9] (for MMC) and Loop up to 8 times waiting for high bit on response to go low R1 = 0x05 (idle and illegal command) Repeat the CMD1 50 times (my arbitrary number to wait until idle clears) Every R1 response is 0x05 (idle and illegal command) Why is OCR all F? Doesn't seem proper at all. Also, why does ACMD41 and CMD1 respond illegal command? Is CMD1 failing because the card is waiting for a valid ACMD after the CMD55 even with the illegal command response? SanDisk ExtremeIII 2G: Set card select high Send 80 SPI clock cycles (done by writing 0xFF 10 times) Set card select low Send CMD0 [0x400000000095] and Loop up to 8 times waiting for high bit on response to go low R1 = 0x01 (idle) Send CMD8 [0x40000001AA87] and Loop up to 8 times waiting for high bit on response to go low R1 = 0x7F (??? My loop shows the responses for each iteration and I got 0xFF 0xFF 0xC1 0x7F... is the card getting out of sync?) Send CMD58 [0x7A00000000FD] and Loop up to 8 times waiting for high bit on response to go low R1 = 0x01 (idle and back in sync) Send 0xFF 4 times to read OCR OCR = 0x00FF80 Send CMD55 [0x770000000065] (1st part of ACMD41) and Loop up to 8 times waiting for high bit on response to go low R1 = 0x5F (??? loop responses are 0xFF 0xFF 0xF0 0x5F... again out of sync?) Send CMD41 [0x6900000000E5] (2nd part of ACMD41) and Loop up to 8 times waiting for high bit on response to go low R1 = 0x05 (idle and illegal command, but back in sync???) Because illegal command, assume card is MMC Send CMD1 [0x4100000000F9] (for MMC) and Loop up to 8 times waiting for high bit on response to go low R1 = 0x7F (??? loop responses are 0xFF 0xFF 0xC1 0x7F... again out of sync?) Repeat CMD1 and Loop up to 8 times waiting for high bit on response to go low R1 = 0x01 (idle) Repeat CMD1 and Loop up to 8 times waiting for high bit on response to go low R1 = 0x7F (??? loop responses are 0xFF 0xFF 0xC1 0x7F... again out of sync?) Repeat CMD1 and Loop up to 8 times waiting for high bit on response to go low R1 = 0x00 (out of idle) Send CMD9 [0x4900000000AF] (get CSD) and Loop up to 8 times waiting for high bit on response to go low R1 = 0x3F (??? loop responses are 0xFF 0xFF 0xC1 0x3F... again out of sync?) Code craps out because Illegal command bit is high. WTF is wrong with that card? Sometimes in sync, other times not. (The above pattern is repeatable.) I've scoped this one out and I'm not seeing any rogue clock cycles going through between MOSI/MISO transfers. Anyone have any clues? Need any more info? Thanx in advance for spending the time to read through all of this.

    Read the article

  • PHP: go back to the start of loop using a sort of 'break' ?

    - by matthy
    Hi i have a loop and i was wondering if there was a command that you can jump back to the start of the loop and ignore the rest of the code in the loop example: for ($index = 0; $index < 10; $index++) { if ($index == 6) that command to go the start of the loop echo "$index, "; } should output 1,2,3,4,5,7,8,9 and skip the six sort of same result as for ($index = 0; $index < 10; $index++) { if ($index != 6) echo "$index, "; } is there a command for that? thanks, matthy

    Read the article

  • Show #14 DotNetNuke 5.6.1, Razor/Webmatrix and WebCamps

    - by Chris Hammond
    Once again, it’s been far too long since the last show, this time just over 4 months, For Show #14 I am joined by Joe Brinkman. Take a listen and see what has been going on in the DNN world. Length: 47:56 Size: 43.8mb MP3 Download Welcome back to DNNVoice Welcome to guest Joe Brinkman ( http://blog.theaccidentalgeek.com/ ) Introduction to Joe and Welcome back from Chris Hammond ( http://www.chrishammond.com ) and what he's been doing DotNetNuke Training Free Extensions Module Development Templates...(read more)

    Read the article

  • MIX 2010 recap podcast

    - by Chris Williams
    from www.slickthought.net: Spaghetti Code Podcast: Recapping the MIX Conference 4/2/2010 11:06:10 AM Spaghetti Code (Jeff Brand) is joined by Mike Hodnic, Jason Bock, Adam Grocholski and Chris Williams to share their thoughts and impressions from the Microsoft MIX Conference and their thoughts on Windows Phone, Silverlight 4, and more. Direct Download - click here Subscribe - click here iTunes - click here

    Read the article

  • Long Running Service Request or COLD CASE?

    - by chris.warticki
    What's going on? Why is it taking so long? Is anyone out there? Resolving Service Requests can seem to take forever. If your Service Request is taking more than a few days, moving into weeks or months, here are few things to consider.  Details here.  Comments welcome. -Chris Warticki twittering @cwarticki Join one of the Twibes - http://twibes.com/OracleSupport or http://twibes.com/MyOracleSupport

    Read the article

  • how to add Go to Page No. function in xtrareport from runtime ?

    - by ahmed
    Hello, I would like to customize my report. I would like to remove the report toolbar and add manual options to export to just only pdf and excel. Exporting to pdf and excel is working fine with me. The only thing now I need is to paging the reports. I want to add something like " go to page No ..." and the user will click the page no. Is this clear ? Any help will be appreciated. Thanking you all.

    Read the article

  • Oracle Linux Friday Spotlight - October 18, 2013

    - by Chris Kawalek
    Happy Friday! Echoing our popular series over on the Oracle Virtualization blog, we'll now be spotlighting something interesting about Oracle Linux for you every Friday. This week, we have a really cool video done by Intel that features Oracle's Phillip Goerl discussing the Oracle Linux development model and how it relates to Intel Xeon. Click below to jump to YouTube and play the video: See you next week! -Chris 

    Read the article

  • GDB question - how do I go through disassembled code line by line?

    - by user324994
    I'd like to go through a binary file my teacher gave me line by line to check addresses on the stack and the contents of different registers, but I'm not extremely familiar with using gdb. Although I have the C code, we're supposed to work entirely from a binary file. Here are the commands I've used so far: (gdb) file SomeCode Which gives me this message: Reading symbols from ../overflow/SomeCode ...(no debugging symbols found)...done. Then I use : (gdb) disas main which gives me all of the assembly. I wanted to set up a break point and use the "next" command, but none of the commands I tried work. Does anyone know the syntax I would use?

    Read the article

  • How to structure an enterprise MVC app, and where does Business Logic go?

    - by James
    I am an MVC newbie. As far as I can tell: Controller: deals with routing requests View: deals with presentation of data Model: looks a whole lot like a Data Access layer Where does the Business Logic go? Take a large enterprise application with: Several different sources of data (WCF, WebServices and ADO) tied together in a data access layer (useing multiple different DTOs). A lot business logic segmented over several dlls. What is an appropriate way for an MVC web application to sit on top of this (in terms of code and project structure)? The example I have seen where everything just goes in the Model folder don't seem like they are appropriate for very large applications. Thanks for any advice!

    Read the article

  • Oracle Linux Friday Spotlight - November 1, 2013

    - by Chris Kawalek
    Happy Friday! I hope you were able to catch our webcast "Why Choose Oracle Linux for your Oracle Database 12c Deployments" earlier this week so you could ask questions of our experts in real-time. But if you didn't, or want to share the content with your colleagues, the on-demand version is our Friday Spotlight this week. Watch now: Why Choose Oracle Linux for your Oracle Database 12c Deployments We'll see you next week! -Chris

    Read the article

  • How do you go from an abstract project description to actual code?

    - by Jason
    Maybe its because I've been coding around two semesters now, but the major stumbling block that I'm having at this point is converting the professor's project description and requirements to actual code. Since I'm currently in Algorithms 101, I basically do a bottom-up process, starting with a blank whiteboard and draw out the object and method interactions, then translate that into classes and code. But now the prof has tossed interfaces and abstract classes into the mix. Intellectually, I can recognize how they work, but am stubbing my toes figuring out how to use these new tools with the current project (simulating a web server). In my professors own words, mapping the abstract description to Java code is the real trick. So what steps are best used to go from English (or whatever your language is) to computer code? How do you decide where and when to create an interface, or use an abstract class?

    Read the article

  • Where can an absolute beginner of Kohana PHP go to learn how to use it from the ground up?

    - by Sergio Tapia
    Hi guys! I have a month of free time and I've decided to launch my own website. It's going to be big and have dymanic content where different users with different roles can perform modifications to the site. Place comments, rate stores, list items, etc. This sound like a perfect opportunity for me to expand my horizons and learn a PHP Framework. I've used PHP bare bones before but nothing too complex. As of now, do you think Kohana is a mature framework to use? I've used Zend in the past for a course in Uni but it sucked horribly, I was new to the MVC model, but Zend had pretty much zero workable tutorials and guides for newbies. That's why I hated it. Where can I go to learn how to use Kohana from a retarded starting point? Thank you very much for your time.

    Read the article

  • Will a Response.Redirect exception go to global.asax?

    - by mgmedick
    I'm aware that when you call Response.Redirect it fires a ThreadAbortException. A co-worker has demonstrated calling response.redirect and then it goes to the global.asax. For the life of me I cannot get the ThreadAbortException to go to the global.asax, its like it is being suppressed naturally in the system. The reason I'm asking this is we believe the response.redirect is the cause of some automated error emails, but I'm not convinced this is the case especially if I can't even get it to debug into the global.asax. Any Ideas why I can't get the Response.Redirect to fire the global error handler?

    Read the article

  • Where did the text of my .html file go in text edit on mac. [closed]

    - by David
    I recently created a .html file in text edit on my mac (os x 10.5.8). I then opened that .html file in my browser and it showed the page i created just fine. I closed the .html file and text edit and refreshed the page. It still worked fine. Then i opened up the .html file in text edit again and all the text was gone (the page in the browser still works fine though). Where did all the text go?

    Read the article

  • Why do Java source files go into a directory structure?

    - by bdhar
    Suppose that I am creating a Java project with the following classes com.bharani.ClassOne com.bharani.ClassTwo com.bharani.helper.HelperOne com.bharani.helper.support.HelperTwo with files put immediately under the folder 'src' src/ClassOne.java src/ClassTwo.java src/HelperOne.java src/HelperTwo.java and compile them using the command $ javac src/*.java -d classes (assuming that classes directory exists) The compiler compiles these files and put the class files in appropriate sub-directories inside the 'classes' directory like this classes/com/bharani/ClassOne.class classes/com/bharani/ClassTwo.class classes/com/bharani/helper/HelperOne.class classes/com/bharani/helper/support/HelperTwo.class Because the spec mandates that the classes should go inside appropriate directory structure. Fine. My question is this: When I use an IDE such as Eclipse or NetBeans, they create the directory structure for the source code directory ('src' directory here) also. Why is that? Is it mandatory? Or, is it just a convention? Thanks.

    Read the article

  • Where can work-at-home coders go to find other coders to real-time chat with and get support like they were on a large team at an established company?

    - by cypherblue
    I used to work in an office surrounded by a large team of programmers where we all used the same languages and had different expertises. Now that I am on my own forming a startup at home, my productivity is suffering because I miss having people I can talk to for specific help, inspiration and reality checks when working on a coding problem. I don't have access to business incubators or shared (co-working) office spaces for startups so I need to chat with people virtually. Where can I go for real-time chat with other programmers and developers (currently I'm looking for people developing for the web, javascript and python) for live debugging and problem-solving of the tasks I am working on? And what other resources can I use to get fellow programmer support?

    Read the article

  • How to go about with real GUI development with Java Swing and MVC.

    - by Myth17
    I am creating a Blackjack Card game emulator. I am a SCJP,familiar with Core Java concepts. I have a very basic understanding of Java swings and awt. Already finished writing the basic game logic,a CLI logic. My design includes several classes like, Dealer,Player,Table,Card,Casino and some others.. Enums for Cards and suite. I have read about MVC as a theoretical concept, familiar with the name 'design patters'(no understanding whatsoever as to how they are implemented) Everywhere I am suggested to learn while writing some real code.So I started off with this... I am stuck now, how should I go about writing code for my project?? Writing the GUI code and organising it within the already existent code.

    Read the article

  • want to go to next view from rightbarbutton item.

    - by uttam
    I am using this code to get the three button on the right side of the navigationbar ,button are visible but next to this I want to go to the next view from this three button image, text ,vedio. NSArray *segmentTextContent = [NSArray arrayWithObjects:@"Image",@"Text",@"Video",nil]; UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:segmentTextContent]; segmentedControl.frame = CGRectMake(13, 20, 150, kCustomButtonHeight); segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; segmentedControl.momentary = YES; defaultTintColor = [segmentedControl.tintColor retain]; // keep track of this for later UIBarButtonItem *segmentBarItem = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl]; self.navigationItem.rightBarButtonItem = segmentBarItem; if(segmentedControl.selectedSegmentIndex=0) { [segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged]; } else if(segmentedControl.selectedSegmentIndex==1) { [segmentedControl addTarget:self action:@selector(segmentAction1:) forControlEvents:UIControlEventValueChanged]; } else if(segmentedControl.selectedSegmentIndex==2) { [segmentedControl addTarget:self action:@selector(segmentAction2:) forControlEvents:UIControlEventValueChanged]; } [segmentBarItem release]; //[modalBarButtonItem release]; } return self; }

    Read the article

  • Is multithreading the right way to go for my case?

    - by Julien Lebosquain
    Hello, I'm currently designing a multi-client / server application. I'm using plain good old sockets because WCF or similar technology is not what I need. Let me explain: it isn't the classical case of a client simply calling a service; all clients can 'interact' with each other by sending a packet to the server, which will then do some action, and possible re-dispatch an answer message to one or more clients. Although doable with WCF, the application will get pretty complex with hundreds of different messages. For each connected client, I'm of course using asynchronous methods to send and receive bytes. I've got the messages fully working, everything's fine. Except that for each line of code I'm writing, my head just burns because of multithreading issues. Since there could be around 200 clients connected at the same time, I chose to go the fully multithreaded way: each received message on a socket is immediately processed on the thread pool thread it was received, not on a single consumer thread. Since each client can interact with other clients, and indirectly with shared objects on the server, I must protect almost every object that is mutable. I first went with a ReaderWriterLockSlim for each resource that must be protected, but quickly noticed that there are more writes overall than reads in the server application, and switched to the well-known Monitor to simplify the code. So far, so good. Each resource is protected, I have helper classes that I must use to get a lock and its protected resource, so I can't use an object without getting a lock. Moreover, each client has its own lock that is entered as soon as a packet is received from its socket. It's done to prevent other clients from making changes to the state of this client while it has some messages being processed, which is something that will happen frequently. Now, I don't just need to protect resources from concurrent accesses. I must keep every client in sync with the server for some collections I have. One tricky part that I'm currently struggling with is the following: I have a collection of clients. Each client has its own unique ID. When a client connects, it must receive the IDs of every connected client, and each one of them must be notified of the newcomer's ID. When a client disconnects, every other client must know it so that its ID is no longer valid for them. Every client must always have, at a given time, the same clients collection as the server so that I can assume that everybody knows everybody. This way if I'm sending a message to client #1 telling "Client #2 has done something", I know that it will always be correctly interpreted: Client 1 will never wonder "but who is Client 2 anyway?". My first attempt for handling the connection of a new client (let's call it X) was this pseudo-code (remember that newClient is already locked here): lock (clients) { foreach (var client in clients) { lock (client) { client.Send("newClient with id X has connected"); } } clients.Add(newClient); newClient.Send("the list of other clients"); } Now imagine that in the same time, another client has sent a packet that translates into a message that must be broadcasted to every connected client, the pseudo-code will be something like this (remember that the current client - let's call it Y - is already locked here): lock (clients) { foreach (var client in clients) { lock (client) { client.Send("something"); } } } An obvious deadlock occurs here: on one thread X is locked, the clients lock has been entered, started looping through the clients, and at one moment must get Y's lock... which is already acquired on the second thread, itself waiting for the clients collection lock to be released! This is not the only case like this in the server application. There are other collections which must be kept in sync with the clients, some properties on a client can be changed by another one, etc. I tried other types of locks, lock-free mechanisms and a bunch of other things. Either there were obvious deadlocks when I'm using too much locks for safety, or obvious race conditions otherwise. When I finally find a good middle point between the two, it usually comes with very subtle race conditions / dead locks and other multi-threading issues... my head hurts very quickly since for any single line of code I'm writing I have to review almost the whole application to ensure everything will behave correctly with any number of threads. So here's my final question: how would you resolve this specific case, the general case, and more importantly: aren't I going the wrong way here? I have little problems with the .NET framework, C#, simple concurrency or algorithms in general. Still, I'm lost here. I know I could use only one thread processing the incoming requests and everything will be fine. However, that won't scale well at all with more clients... But I'm thinking more and more to go this simple way. What do you think? Thanks in advance to you, StackOverflow people which have taken the time to read this huge question. I really had to explain the whole context if I want to get some help.

    Read the article

  • What are the key steps a Developer needs to go through to become a good Project Manager?

    - by adpd
    I am a full-time Developer who aspires to be a great technical Project Manager. What are the key steps that you think I need to go through to achieve that aspiration? I am interested in professional qualifications (e.g. PRINCE2, etc.), training courses, personality traits, experiences, tips and techniques that would improve my chances of being the best I can be. I would be interested in hearing if anybody has done this, and whether they are happy with their change from development or if they wished they had stuck to a development (and the reasons behind this decision).

    Read the article

  • In Visual Studio 2008, how can I make control+click do a "Go To Definition"?

    - by Blorgbeard
    I know this is not strictly about programming, but it's pretty close. Anyway, in Delphi, you can hold control and click on a method to jump to its definition. In VS2008, you have to right-click and select "Go To Definition". I use this function quite often, so I'd really like to get VS to behave like delphi in this regard - its so much quicker to ctrl+click. I don't think there's a way to get this working in base VS2008 - am I wrong? Or maybe there's a plugin I could use? Edit: Click then F12 does work - but isn't really a good solution for me.. It's still way slower than ctrl+click. I might try AutoHotkey, since I'm already running it for something else. Edit: AutoHotkey worked for me. Here's my script (I'm a complete n00b, so it's probably suboptimal): SetTitleMatchMode RegEx #IfWinActive, .* - Microsoft Visual Studio ^LButton::Send {click}{f12}

    Read the article

  • Select Menu, go to url on select with JQuery?

    - by Keith Donegan
    Hey Guys, I have the following html: HTML markup <ul id="test"> <li><a href="http://www.yahoo.com">yahoo</a></li> <li><a href="http://www.google.com">Google</a></li> </ul> And some JS code: JQuery/JavaScript Code $('ul#test').each(function() { var select=$(document.createElement('select')).insertBefore($(this).hide()); $('>li a', this).each(function() { option=$(document.createElement('option')).appendTo(select).val(this.href).html($(this).html()); }); }); This code produces a select dropdown menu, exactly what I want, but my question is how do I go to the url on select? So if I click yahoo, it brings me to yahoo.com? Thanks for your help!

    Read the article

  • how to go the middle of the singularly linked list in one iteration?

    - by u3050
    Recently I have been asked one question that in a singularly linked list how do we go to the middle of the list in one iteration. A --> B --> C --> D (even nodes) for this it should return address which points to B A --> B --> C (odd nodes) for this also it should return address which points to B There is one solution of taking two pointers one moves one time and other moves two times but it does not seem working here LinkedList p1,p2; while(p2.next != null) { p1 = p1.next; p2 = p2.next.next; } System.out.print("middle of the node" + p1.data); //This does not give accurate result in odd and even Please help if anyone has did this before.

    Read the article

< Previous Page | 30 31 32 33 34 35 36 37 38 39 40 41  | Next Page >