Search Results

Search found 8588 results on 344 pages for 'thread abort'.

Page 143/344 | < Previous Page | 139 140 141 142 143 144 145 146 147 148 149 150  | Next Page >

  • WCF - Automatically create ServiceHost for multiple services

    - by Rajesh Pillai
    WCF - Automatically create ServiceHost for multiple services Welcome back readers!  This blog post is about a small tip that may make working with WCF servicehost a bit easier, if you have lots of services and you need to quickly host them for testing. Recently I was encountered a situation where we were faced to create multiple service host quickly for testing.  Here is the code snippet which is pretty self explanatory.  You can put this code in your service host which in this case is  a console application. class Program   {       static void Main(string[] args)       { // Stores all hosts           List<ServiceHost> hosts = new List<ServiceHost>();           try           { // Get the services element from the serviceModel element in the config file               var section = ConfigurationManager.GetSection("system.serviceModel/services") as ServicesSection;               if (section != null)               {                   foreach (ServiceElement element in section.Services)                   { // NOTE : If the assembly is in another namespace, provide a fully qualified name here in the form // <typename, namespace> // For e.g. Business.Services.CustomerService, Business.Services                       var serviceType = Type.GetType(element.Name); // Get the typeName                        var host = new ServiceHost(serviceType);                       hosts.Add(host); // Add to the host collection                       host.Open(); // Open the host                   }               }               Console.ReadLine();           }           catch (Exception e)           {               Console.WriteLine(e.Message);               Console.ReadLine();           }           finally           {               foreach (ServiceHost host in hosts)               {                   if (host.State == CommunicationState.Opened)                   {                       host.Close();                   }                   else                   {                       host.Abort();                   }               }           }       }   } I hope you find this useful.  You can make this as a windows service if required.

    Read the article

  • HTML5 media loading sometimes suspends or aborts: misconfigured Apache?

    - by Joan Botella
    Recently, some code that has been working fine for months started to run unexpectedly. That code is just a media files loading JavaScript function, that uses jQuery. It's pretty long, but in essence it is like this: var $audio=$('<audio>'); $audio.on('canplaythrough',function(e){ $audio[0].play(); }); $audio.attr('src','song.ogg'); Basically, the file only loads sometimes, and sometimes stops loading with a suspend or even an abort event. I have uploaded a little testing HTML to http://www.joanbotella.com/tests/loading , where you can see what's happening. You can download the test files from http://www.joanbotella.com/tests/loading/loadingTest.zip for local testing. I have just checked that opening the test index.html file directly into Firefox, and not through my localhost Apache server, makes the audio files perfectly playable. So, I assume, my hosting and I have the Apache server misconfigured for serving media files. My software versions are: Apache 2.2.22-1ubuntu1.7 , Mozilla Firefox 31.0 , Chromium 36.0.1985.125 and jQuery 1.11.0. Can you help me? Thanks in advance!

    Read the article

  • SQL server periodically gets disconnected

    - by Maulin
    Hi, Our environment is: Windows Server 2003, Service Pack 2 SQL Server Express 2005 SQLServer JDBC driver 1.2 (also tried Jtds) Sun JDK 1.6 (we tried this on JDK 1.5 as well) There is no virus protection software on the host, and no firewall is enabled. We have Web application deployed in JBOSS 4.0.2. Our problem is that the JDBC connection to SQL server periodically gets disconnected, and then we can't reconnect to the SQL server at all, unless we physically restart the server on which JBOSS deployed. we are getting following error in log. Software caused connect on abort: recv failed Note: We are able to connect to SQL server using sample java test class. Any suggestions would be most appreciated, as this is a serious, mission-criticial problem for us right now.

    Read the article

  • Is there a clean way to tell Windows to release a volume?

    - by zneak
    Hey guys, I'm trying, under Windows 7, to run a virtual machine with VMWare Player from an OS installed on a physical partition. However, when I boot the virtual machine, VMWare Player says that it couldn't access the physical drive and has to abort there. This seems to be a generally acknowledged problem in the VMWare community, as Windows Vista introduced a compelling new security feature that makes it impossible to write to a raw drive without obtaining exclusive access to it. I have googled the issue and found a few workarounds. However, the clean ones seem to only work on whole physical disks, and not on partitions. So I would be left with the dirty solution. In short, it meddles with the MBR to erase any trace of the partitions to use, makes Windows forget about them, then restores the MBR so we can launch the VM. Is there a way to let VMWare acquire exclusive access to the partition without requiring me to nuke it away?

    Read the article

  • Easy way to update apache on a server cluster with shared NFS conf?

    - by Simon
    we have a server setup where a server cluster connected with a db/files/conf server shared by nfs serve our sites, behind an Elastic Load Balancer at Amazon EC2. The setup works correctly, but keeping it up to date is becoming like hell, because the apache/php conf that webservers use is shared through NFS. So, if we try to run an apt-get upgrade on a server on the cluster, it will abort it due to the webserver is not able to write back the configuration to the nfs server. Every time we want to update the machines, or install a package like php-curl, we need to create a new ami, so the changes will reflect on the new launched amis. Could it be another way of doing the things simpler? Thanks in advance!

    Read the article

  • How can I get my ATI / AMD drivers to work with any kernel above 3.2.0.x?

    - by TorakTu
    How can I get my ATI / AMD drivers to work with any kernel above 3.2.0.x ? WHAT DID WORK Installed original AMD64 version of Ubuntu 12.04 ISO image. Burned DVD and installed which shown kernel 3.2.0-23 to begin with. Got 5.1 surround sound working. Got ATI ( Now its AMD ) video drivers installed for my Radeon HD R6870 Video card from AMD's website. fglrxinfo came up and reported as normal. THE PROBLEM Kernel 3.2.0.x kept locking up so I tried higher kernel versions. But ATI / AMD Drivers do not install on any kernel Above 3.2.0.x WHAT I HAVE TRIED I have gone over this tutorial many times ( https://help.ubuntu.com/community/BinaryDriverHowto/ATI ) and it doesn't work on ANY kernel except 3.2.0.x. The problems I am having here are that the ATI / AMD drivers working for the 12.04 Precise with kernel 3.2.0-23 and 24, But the computer kept locking up. Although all my games would work, the lock ups were random and were constant. So I looked all over the web for 3 days trying to find an answer and the lock up issue was said to just update the kernel. So I did. Have tried many kernels. All of them .. no lock ups. BUT the Restricted AMD drivers from the AMD website will not install. And none of the OpenSource AMD drivers have EVER installed no matter what Kernel or version I tried. EXAMPLE OUTPUT OF 3D TYPE OF ERRORS Javax.media.opengl.GLException: glXGetConfig failed: error code GLX_NO_EXTENSION at com.sun.opengl.impl.x11.X11GLDrawableFactory.glXGetConfig(X11GLDrawableFactory.java:651) at com.sun.opengl.impl.x11.X11GLDrawableFactory.xvi2GLCapabilities(X11GLDrawableFactory.java:350) at com.sun.opengl.impl.x11.X11GLDrawableFactory.chooseGraphicsConfiguration(X11GLDrawableFactory.java:174) at javax.media.opengl.GLCanvas.chooseGraphicsConfiguration(GLCanvas.java:520) at javax.media.opengl.GLCanvas.<init>(GLCanvas.java:131) at haven.HavenPanel.<init>(HavenPanel.java:68) at haven.HavenPanel.<init>(HavenPanel.java:78) at haven.MainFrame.<init>(MainFrame.java:182) at haven.MainFrame.main2(MainFrame.java:306) at haven.MainFrame.access$100(MainFrame.java:34) at haven.MainFrame$7.run(MainFrame.java:360) at java.lang.Thread.run(Thread.java:722) And of course this is what fglrxinfo shows : X Error of failed request: BadRequest (invalid request code or no such operation) Major opcode of failed request: 139 (ATIFGLEXTENSION) Minor opcode of failed request: 66 () Serial number of failed request: 13 Current serial number in output stream: 13 EDIT : I forgot to mention that I DID look at this post over the last few days and it did not help.

    Read the article

  • Creating Asynchronous Methods in EJB 3.1

    - by cindo
    Normal 0 false false false EN-US X-NONE X-NONE /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} OBE of the Month: Creating Asynchronous Methods in EJB 3.1 This OBE covers creating an EJB 3.1 application that demonstrates the use of the @Asynchronous annotation in an Enterprise Java Bean (EJB) class or specific method. In this tutorial, you will create a Java EE 6 Web Application and add the following components to it - a Stateless Session Bean with two asynchronous methods. You define a Servlet to call the asynchronous methods and to keep track of the invocation and completion times to demonstrate the asynchronous nature of the method calls. The index.jsp will contain a form with a submit button, Run allowing you to execute the application. The form will submit to the Servlet which invokes the asynchronous methods defined in the session bean and the response is re-directed to response.jsp. Information about the asynchronous handling procedure is displayed to users. From this information, users will notice that the invoker thread and the called asynchronous thread are working concurrently. Check out this new OBE on the Oracle Learning Library: Creating Asynchronous Methods in EJB 3.1. This OBE is part of the new EJB 3.1 New Features Series. Related OBE’s that might interest you: Creating a No-Interface View Session Bean and Packaging in a WAR File Creating and Accessing a Session Bean in a  Web Application

    Read the article

  • Converting NUnit tests to MSUnit.

    - by TATWORTH
    I created the MSTest project by creating a new class library project and copying the test classes to it. I then followed the instructions in the following posts.http://social.msdn.microsoft.com/Forums/en/vststest/thread/eeb42224-bc1f-476d-98b4-93d0daf44aadhttp://dangerz.blogspot.co.uk/2012/01/converting-nunit-to-mstest.htmlHowever I did not need to add the GUID fix as I used ReSharper to run both sets of tests.

    Read the article

  • Mercurial says hgrc is untrusted in Emacs, but works fine from the command line

    - by Ken
    I've got some Mercurial checkouts in a directory that was mounted by root. Mercurial is usually suspicious of files that aren't mine, but I'm the only user here, so I put: [trusted] users = root groups = root in my ~/.hgrc, and now I can use hg from the command line with no warnings or errors about anything being untrusted. So far, great. But when I try to run, say, vc-annotate in Emacs, I get an Annotate buffer that says: abort: unknown revision 'Not trusting file /home/me/.../working-copy/.hg/hgrc from untrusted user root, group root Not trusting file /home/me/.../working-copy/.hg/hgrc from untrusted user root, group root 7648'! The message area says: Running hg annotate -d -n --follow -r... my-file.c...FAILED (status 255) I don't have anything in my .emacs related to vc or hg. Other commands, like vc-diff, work fine. What am I missing here?

    Read the article

  • What happens when a HTTP request is terminated prematurely?

    - by Gowtham
    Suppose, I enter a URL in my browser and browser submits the HTTP request. The remote HTTP server accepts the request and initiates a long task to serve the request. If I terminate the request before it is complete (for example, press Esc or in Firefox), how is the request closed? Will the browser communicate this abort request to the server (I think it doesn't)? Presuming no, upon completion of the long task, what will the server do with the result? Does it send it back anyway? If it does, what will happen? Does it reach till my PC? Or gets lost on the way? This is just for my curiosity. Thanks for your time :)

    Read the article

  • Programming Language most relevant to the Financial sector?

    - by NoviceCoding
    I am a freshman in college and doing a software engineering/ finance double major. I've been learning programming on my own and have a good bit of familiarity with php by now. I was wondering what you guys think the most relevant programming language is for financial/investment banking use? I have read this thread: Books on developing software for financial markets/investment banks I want to start learning/reading up on a language (the basics not financial/quant stuff) to set a foundation for the future financial/quant stuff.

    Read the article

  • Q: MySQL Cluster - Data insertion in NDBCLUSTER table - error out after 5 million rows

    - by Mata
    MysqlCluster version: mysql-5.6.11 ndb-7.3.2 Insertload = 50 M dataset Datanodes = 3 LOAD DATA INFILE '/input_50m/Table_1_sorted.csv' IGNORE INTO TABLE nw_ndb FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' We recently setup a new mySQL cluster and trying to load data from a flat file. But getting error “Got temporary error 4010 'Node failure caused abort of transaction' from NDBCLUSTER" when inserting 5 million rows in a single table in MySQL Cluster. We are using "LOAD DATA INFILE" command to load the data in the table from csv file. Server (musqld, ndb nodes) has good hardware: 126 GB RAM, 32 Gb allocated to mysqld tried below settings with no effect: SET autocommit=0; SET FOREIGN_KEY_CHECKS=0; SET unique_checks=0; SET GLOBAL ndb_batch_size=8*1024*1024; SET GLOBAL ndb_cache_check_time = 1000; SET GLOBAL ndb_index_stat_cache_entries = 10000000; SET SESSION BULK_INSERT_BUFFER_SIZE=256217728; SET GLOBAL KEY_BUFFER_SIZE=256217728; Any clues?

    Read the article

  • What is the difference between "data hiding" and "encapsulation"?

    - by Software Engeneering Learner
    I'm reading "Java concurrency in practice" and there is said: "Fortunately, the same object-oriented techniques that help you write well-organized, maintainable classes - such as encapsulation and data hiding -can also help you create thread-safe classes." The problem #1 - I never heard about data hiding and don't know what it is. The problem #2 - I always thought that encapsulation is using private vs public, and is actually the data hiding. Can you please explain what data hiding is and how it differs from encapsulation?

    Read the article

  • Force '^C' to be printed when editing current prompt, then aborting it

    - by Stefan Lasiewski
    This is the opposite of Prevent “^C” from being printed when aborting editing current prompt. I'm using Bash. When I'm editing the commandline in Bash, and I hit Control-C to abort the commandline, the '^C' character does not display. I would like to see this character. I tried commands like stty -ctlecho and stty ctlecho (which I borrowed from the other question), but this didn't work for me. This behavior seems to be true with my environment on Ubuntu, CentOS and MacOSX.

    Read the article

  • How to install Opera Browser?

    - by bruce
    I am trying to install opera browser from the terminal. I downloaded the 'debian' installer because it didn't show up in software center. It completely destroyed my software center - it is frozen and I have no idea how to fix (I have a different thread for that though). Can I use this thing called synaptic package manager to install Opera? or am I stuck with Firefox? How do I install Opera Browser?

    Read the article

  • How to reliably run a batch job every 5 seconds?

    - by Benjamin
    I'm building an application where the sending of all notifications (email, SMS, fax) will be asynchronous. The application will write the notifications to the database, and a batch job will read these notifications and send them with the appropriate transport. I was first reading at ways to run cron faster than the minute, and realized this was a bad idea. The batch scripts are written in PHP, and I guess that writing a proper daemon would be quite an overhead (though I'm open to any suggestion, as PHP car run indefinitely as well). What I have in mind is a solution that would: Run the PHP script every 5 seconds Check that the previous run has finished, or abort (never 2 concurrent batches running) Kill the script if live for more than x minutes (a security in case it hangs) Start with the system (if a reboot occurs) Any idea how to do this?

    Read the article

  • 12.10 install overwrote my windows partition

    - by Niall C
    Recently decided to switch back to Ubuntu. I have a 3TB drive which was running win7. I had 3 partitions. c: for windows d: data e: data Have installed ubuntu before so 'thought' I knew what I was doing. I using netbootin I installed from a usb stick. I didn't choose the default options but I didn't choose the 'manual install' either. I can't remember what option I took but I figured at some stage it would tell me how it was going to partition the disk and at that stage I would see if it had recognised the NTFS partitions and I would be able to abort if it didn't. Unfortunately, it didn't and just went ahead and installed Ubuntu and made up it's own mind on how it was going to partition the disk. Usual story, the two NTFS data partitions weren't backed up. Is there anything I can do to retrieve the ntfs data? I'm currently trying out testdisk and I know I can use photodisk to retrieve certain file types but all the filenames will be lost and it's going to take a hell of a lot of time to rename them all. Any help or assistance would be more than gratefully accepted. Thanks in advance, Niall

    Read the article

  • SharePoint 2010 HierarchicalConfig Caching Problem

    - by Damon
    We've started using the Application Foundations for SharePoint 2010 in some of our projects at work, and I came across a nasty issue with the hierarchical configuration settings.  I have some settings that I am storing at the Farm level, and as I was testing my code it seemed like the settings were not being saved - at least that is what it appeared was the case at first.  However, I happened to reset IIS and the settings suddenly appeared.  Immediately, I figured that it must be a caching issue and dug into the code base.  I found that there was a 10 second caching mechanism in the SPFarmPropertyBag and the SPWebAppPropertyBag classes.  So I ran another test where I waited 10 seconds to make sure that enough time had passed to force the caching mechanism to reset the data.  After 10 minutes the cache had still not cleared.  After digging a bit further, I found a double lock check that looked a bit off in the GetSettingsStore() method of the SPFarmPropertyBag class: if (_settingStore == null || (DateTime.Now.Subtract(lastLoad).TotalSeconds) > cacheInterval)) { //Need to exist so don't deadlock. rrLock.EnterWriteLock(); try { //make sure first another thread didn't already load... if (_settingStore == null) { _settingStore = WebAppSettingStore.Load(this.webApplication); lastLoad = DateTime.Now; } } finally { rrLock.ExitWriteLock(); } } What ends up happening here is the outer check determines if the _settingStore is null or the cache has expired, but the inner check is just checking if the _settingStore is null (which is never the case after the first time it's been loaded).  Ergo, the cached settings are never reset.  The fix is really easy, just add the cache checking back into the inner if statement. //make sure first another thread didn't already load... if (_settingStore == null || (DateTime.Now.Subtract(lastLoad).TotalSeconds) > cacheInterval) { _settingStore = WebAppSettingStore.Load(this.webApplication); lastLoad = DateTime.Now; } And then it starts working just fine. as long as you wait at least 10 seconds for the cache to clear.

    Read the article

  • OSB, Service Callouts and OQL - Part 2

    - by Sabha
    This section of the "OSB, Service Callouts and OQL" blog posting will delve into thread dump analysis of OSB server and detecting threading issues relating to Service Callout using ThreadLogic. We would also use Heap Dump and OQL to identify the related Proxies and Business services. The previous section dealt with threading model used by OSB to handle Route and Service Callouts. Please refer to the blog post for more details.

    Read the article

  • Control scheduled tasks execution

    - by SJuan76
    We are a small shop. I am mainly a programmer, but due to being the only one that risks to manage our servers, the task has fallen on me (yet I it is still a secondary function so I cannot give it too much time). Over the course of years we have needed to create a decent number of .bat scripts that run as scheduled tasks in our servers (dump DB servers, SVN servers, copy files, etc.). Manually checking that everyone has proceeded ok is a time consuming task. I could get them to send an email on completion, but then I would get swarmed by lots of emails each morning. If I setup them to only e-mail on failure, I might miss the instances where the error causes the task to abort (or even not to start). Are there other alternatives? We are currently using Windows 2003 R2, but we are thinking of adding some Linux server soon, so a cross-platform solution would be best.

    Read the article

  • Android - Force Close - Null Pointer on Canvas?

    - by user22241
    Please bear with me. I have a very odd problem. Basically, my app so far, has 3 activities (a main splash screen, an 'options/menu' screen and the main app). If I follow the very specific steps oulined below, I get a 'null pointer exception' in the 2nd activity) and the app force closes...... Here are the steps: Start the app (a game based on Surfaceview), tap through to the third activity so the game is running, then hit the home key so the game is paused and put to the background, the activity/app is ended through DDMS in the SDK then restarted on the device (all OK so far), now if I hit the back key on the device twice in quick succession, it happens. All other sequence of events is fine, even to the point of pressing the back key, waiting for the previous activity to show, then hitting back again - all OK. Only when the back key is pressed twice in quick succession following all the above steps does the problem occur. I'm assuming that the canvas isn't ready as it's showing as 'null' when this happens, but I'm not sure why this is happening as surely it's happening when I'm trying to go back to activity 1, but the logcat shows the error in activity 2. if I stop the activity running my 'doDraw' method (which referenced the canvas), then all is OK - so I can safely assume it is the canvas causing the problem. Also, if I skip my first activity (which is a very basic full-screen button which just displays a splashscreen and waits for the user to tap the screen), and make my 2nd activity the launch activity, again, it is OK. this is the part of the code that I think is probably relevant: @Override public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) { vheight = this.getHeight(); vwidth = this.getWidth(); } @Override public void surfaceCreated(SurfaceHolder holder) { vheight = this.getHeight(); vwidth = this.getWidth(); this.viewWidth = vwidth; this.viewHeight = vheight; if (runthread==false){ if (preThread.getState()==Thread.State.TERMINATED){ preThread = new OptionsThread(thisholder, thiscontext, thishandler); } preThread.setRunning(true); preThread.start();} } @Override public void surfaceDestroyed(SurfaceHolder holder) { preThread.setRunning(false); //Stop the loop boolean retry = true; //Stop the thread while (retry) { try { preThread.join(); retry = false; } catch (InterruptedException e) { } } Thank you all for any help you can offer

    Read the article

  • Generate md5 and other checksums from properties menu (added "Digests" tab)

    - by Chuck
    I am trying to restore a function that I had on my last box. It added a tab in the properties menu of any file called "Digests". From there I could choose any/all of the hash formats, click hash and it would generate said checksums right there. What I am trying to find out is either the name of the package or acquire the location of it's installation. I have started a thread on UbuntuForums pertaining to this already

    Read the article

  • How to wipe the slate clean on an Oracle installation?

    - by nw
    After a basic, successful installation of Oracle 11g, I ran dbca again to enable Enterprise Manager on my database. The operation hung at around 67% for half an hour or more, so I clicked Stop to abort the operation. Things seemed to wrap up cleanly, EM was working, all was well with the world. Then I started getting this dreaded error upon any attempt to connect in SQL*Plus: ORA-12154: TNS:could not resolve the connect identifier specified I thought perhaps the database had been corrupted due to the earlier aborted operation, so I ran dbca again and deleted the database. Then I attempted to create a new database in its stead, using a clone of the template created the first time around. Unfortunately, the clone database operation fails at 50% with the exact same error: ORA-12154: TNS:could not resolve the connect identifier specified How can I clean up the mess I have created, short of reinstalling Oracle entirely from scratch?

    Read the article

  • When I run Android SDK from terminal, it shows error. How to fix it?

    - by diflame
    Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-gtk-3550 or swt-gtk in swt.library.path, java.library.path or the jar file at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source) at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source) at org.eclipse.swt.internal.C.<clinit>(Unknown Source) at org.eclipse.swt.internal.Converter.wcsToMbcs(Unknown Source) at org.eclipse.swt.internal.Converter.wcsToMbcs(Unknown Source) at org.eclipse.swt.widgets.Display.<clinit>(Unknown Source) at com.android.sdkmanager.Main.showSdkManagerWindow(Main.java:328) at com.android.sdkmanager.Main.doAction(Main.java:316) at com.android.sdkmanager.Main.run(Main.java:118) at com.android.sdkmanager.Main.main(Main.java:101)

    Read the article

  • Entity Framework 5, separating business logic from model - Repository?

    - by bnice7
    I am working on my first public-facing web application and I’m using MVC 4 for the presentation layer and EF 5 for the DAL. The database structure is locked, and there are moderate differences between how the user inputs data and how the database itself gets populated. I have done a ton of reading on the repository pattern (which I have never used) but most of my research is pushing me away from using it since it supposedly creates an unnecessary level of abstraction for the latest versions of EF since repositories and unit-of-work are already built-in. My initial approach is to simply create a separate set of classes for my business objects in the BLL that can act as an intermediary between my Controllers and the DAL. Here’s an example class: public class MyBuilding { public int Id { get; private set; } public string Name { get; set; } public string Notes { get; set; } private readonly Entities _context = new Entities(); // Is this thread safe? private static readonly int UserId = WebSecurity.GetCurrentUser().UserId; public IEnumerable<MyBuilding> GetList() { IEnumerable<MyBuilding> buildingList = from p in _context.BuildingInfo where p.Building.UserProfile.UserId == UserId select new MyBuilding {Id = p.BuildingId, Name = p.BuildingName, Notes = p.Building.Notes}; return buildingList; } public void Create() { var b = new Building {UserId = UserId, Notes = this.Notes}; _context.Building.Add(b); _context.SaveChanges(); // Set the building ID this.Id = b.BuildingId; // Seed 1-to-1 tables with reference the new building _context.BuildingInfo.Add(new BuildingInfo {Building = b}); _context.GeneralInfo.Add(new GeneralInfo {Building = b}); _context.LocationInfo.Add(new LocationInfo {Building = b}); _context.SaveChanges(); } public static MyBuilding Find(int id) { using (var context = new Entities()) // Is this OK to do in a static method? { var b = context.Building.FirstOrDefault(p => p.BuildingId == id && p.UserId == UserId); if (b == null) throw new Exception("Error: Building not found or user does not have access."); return new MyBuilding {Id = b.BuildingId, Name = b.BuildingInfo.BuildingName, Notes = b.Notes}; } } } My primary concern: Is the way I am instantiating my DbContext as a private property thread-safe, and is it safe to have a static method that instantiates a separate DbContext? Or am I approaching this all wrong? I am not opposed to learning up on the repository pattern if I am taking the total wrong approach here.

    Read the article

< Previous Page | 139 140 141 142 143 144 145 146 147 148 149 150  | Next Page >