Search Results

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

Page 134/344 | < Previous Page | 130 131 132 133 134 135 136 137 138 139 140 141  | Next Page >

  • C++ Virtual Constructor, without clone()

    - by Julien L.
    I want to perform "deep copies" of an STL container of pointers to polymorphic classes. I know about the Prototype design pattern, implemented by means of the Virtual Ctor Idiom, as explained in the C++ FAQ Lite, Item 20.8. It is simple and straightforward: struct ABC // Abstract Base Class { virtual ~ABC() {} virtual ABC * clone() = 0; }; struct D1 : public ABC { virtual D1 * clone() { return new D1( *this ); } // Covariant Return Type }; A deep copy is then: for( i = 0; i < oldVector.size(); ++i ) newVector.push_back( oldVector[i]->clone() ); Drawbacks As Andrei Alexandrescu states it: The clone() implementation must follow the same pattern in all derived classes; in spite of its repetitive structure, there is no reasonable way to automate defining the clone() member function (beyond macros, that is). Moreover, clients of ABC can possibly do something bad. (I mean, nothing prevents clients to do something bad, so, it will happen.) Better design? My question is: is there another way to make an abstract base class clonable without requiring derived classes to write clone-related code? (Helper class? Templates?) Following is my context. Hopefully, it will help understanding my question. I am designing a class hierarchy to perform operations on a class Image: struct ImgOp { virtual ~ImgOp() {} bool run( Image & ) = 0; }; Image operations are user-defined: clients of the class hierarchy will implement their own classes derived from ImgOp: struct CheckImageSize : public ImgOp { std::size_t w, h; bool run( Image &i ) { return w==i.width() && h==i.height(); } }; struct CheckImageResolution; struct RotateImage; ... Multiple operations can be performed sequentially on an image: bool do_operations( std::vector< ImgOp* > v, Image &i ) { std::for_each( v.begin(), v.end(), /* bind2nd(mem_fun(&ImgOp::run), i ...) don't remember syntax */ ); } int main( ... ) { std::vector< ImgOp* > v; v.push_back( new CheckImageSize ); v.push_back( new CheckImageResolution ); v.push_back( new RotateImage ); Image i; do_operations( v, i ); } If there are multiple images, the set can be split and shared over several threads. To ensure "thread-safety", each thread must have its own copy of all operation objects contained in v -- v becomes a prototype to be deep copied in each thread.

    Read the article

  • Java Swing app hangs when run in normal mode but runs fine in debug mode

    - by snocorp
    I am writing a basic Java application with a Swing front-end. Basically it loads some data from a Derby database via Apache Cayenne and then displays it in a JTable. I'm doing my development in Eclipse and I don't think it's important but I'm using Maven for dependencies. Now this works fine when I run using Debug but it seems to hang the display thread when I use the Run button. I've done a thread dump and I'm not 100% certain but everything looks good. I used Java VisualVM and the threads look fine there as well. Strangely it seems to work intermittently. It's pretty consistent though and easy to reproduce. If anyone has any ideas, I'm all out of them.

    Read the article

  • How to automatically run in the background?

    - by Hun1Ahpu
    I'm not sure that it's not implemented yet, I hope that it is. But I know that in .Net programmers should manually run time-consuming task in the background thread. So every time we handle some UI event and we understand that this will take some time we also understand that this will hang UI thread and our application. And then we make all this Background work things and handle callbacks or whatever. So my question is: Is there in some language/platform a mechanism that will automatically run time-consuming tasks in the background and will do all related work itself? So we just write the code for handling specific UI event and this code will be somehow detected as time-consuming and will be executed in background. And if there isn't, then why?

    Read the article

  • Gapless (looping) audio playback with DirectX in C#

    - by horsedrowner
    I'm currently using the following code (C#): private static void PlayLoop(string filename) { Audio player = new Audio(filename); player.Play(); while (player.Playing) { if (player.CurrentPosition >= player.Duration) { player.SeekCurrentPosition(0, SeekPositionFlags.AbsolutePositioning); } System.Threading.Thread.Sleep(100); } } This code works, and the file I'm playing is looping. But, obviously, there is a small gap between each playback. I tried reducing the Thread.Sleep it to 10 or 5, but the gap remains. I also tried removing it completely, but then the CPU usage raises to 100% and there's still a small gap. Is there any (simple) way to make playback in DirectX gapless? It's not a big deal since it's only a personal project, but if I'm doing something foolish or otherwise completely wrong, I'd love to know. Thanks in advance.

    Read the article

  • Connection hangs after time of inactivity

    - by Sinuhe
    In my application, Spring manages connection pool for database access. Hibernate uses these connections for its queries. At first glance, I have no problems with the pool: it works correctly with concurrent clients and a pool with only one connection. I can execute a lot of queries, so I think that I (or Spring) don't leave open connections. My problem appears after some time of inactivity (sometimes 30 minutes, sometimes more than 2 hours). Then, when Hibernate does some search, it lasts too much. Setting log4j level to TRACE, I get this logs: ... 18:27:01 DEBUG nsactionSynchronizationManager - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@99abd7] for key [org.hibernate.impl.SessionFactoryImpl@7d2897] bound to thread [http-8080-Processor24] 18:27:01 DEBUG HibernateTransactionManager - Found thread-bound Session [org.hibernate.impl.SessionImpl@8878cd] for Hibernate transaction 18:27:01 DEBUG HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@1b2ffee] 18:27:01 DEBUG HibernateTransactionManager - Creating new transaction with name [com.acjoventut.service.GenericManager.findByExample]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT 18:27:01 DEBUG HibernateTransactionManager - Preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@8878cd] 18:27:01 TRACE SessionImpl - setting flush mode to: AUTO 18:27:01 DEBUG JDBCTransaction - begin 18:27:01 DEBUG ConnectionManager - opening JDBC connection Here it gets frozen for about 2 - 10 minutes. But then continues: 18:30:11 DEBUG JDBCTransaction - current autocommit status: true 18:30:11 DEBUG JDBCTransaction - disabling autocommit 18:30:11 TRACE JDBCContext - after transaction begin 18:30:11 DEBUG HibernateTransactionManager - Exposing Hibernate transaction as JDBC transaction [jdbc:oracle:thin:@212.31.39.50:30998:orcl, UserName=DEVELOP, Oracle JDBC driver] 18:30:11 DEBUG nsactionSynchronizationManager - Bound value [org.springframework.jdbc.datasource.ConnectionHolder@843a9d] for key [org.apache.commons.dbcp.BasicDataSource@7745fd] to thread [http-8080-Processor24] 18:30:11 DEBUG nsactionSynchronizationManager - Initializing transaction synchronization ... After that, it works with no problems, until another period of inactivity. IMHO, it seems like connection pool returns an invalid/closed connection, and when Hibernate realizes that, ask another connection to the pool. I don't know how can I solve this problem or things I can do for delimiting it. Any help achieving this will be appreciate. Thanks. EDIT: Well, it finally was due a firewall rule. Database detects the connection is lost, but pool (dbcp or c3p0) not. So, it tries to query the database with no success. What is still strange for me is that timeout period is very variable. Maybe the rule is specially strange or firewall doesn't work correctly. Anyway, I have no access to that machine and I can only wait for an explanation. :(

    Read the article

  • Dynamically find other hosts in a LAN in Java

    - by Federico Cristina
    A while ago I developed a little LAN chat app. in Java which allows chatting with other hosts, send images, etc. Although it was created just for fun, now it's being used where I work. Currently, there is no "chat server" on the app. where each client registers, updates it's status, etc. (I liked the idea of symmetric design and not depending on a server running on some other machine). Instead, each host is a client/server which has a hosts.properties file with the hostname of the other hosts, and - for instance - broadcasts to each one of them when sending a massive message/image/whatever. In the beginning there were just a couple of hosts, so this hosts.properties file wasn't an issue. But as the amount of users increased, the need of updating that file was a bit daunting. So now I've decided to get rid of it, and each time the app. starts, dynammically find the other active hosts. However, I cannot find the correct way of implement this. I've tried starting different threads, each one of them searching for other hosts in a known range of IP addresses. Something like this (simplified for the sake of readability): /** HostsLocator */ public static void searchForHosts(boolean waitToEnd) { for (int i=0; i < MAX_IP; i+= MAX_IP / threads) { HostsLocator detector = new HostsLocator(i, i+(MAX_IP / threads - 1)); // range: from - to new Thread(detector).start(); } } public void run() { for (int i=from; i<=to; i++) findHosts( maskAddress + Integer.toString(i) ); } public static boolean findHosts(String IP) { InetAddress address = InetAddress.getByName(IP); if ( address.isReachable(CONNECTION_TIME_OUT) ) // host found! } However: With a single thread and a low value in CONNECTION_TIME_OUT (500ms) I get wrong Host Not Found status for for hosts actually active. With a high value in CONNECTION_TIME_OUT (5000ms) and only one single thread takes forever to end With several threads I've also found problems similar like the first one, due to collisions. So... I guess there's a better way of solving this problem but I couldn't find it. Any advice? Thanks!

    Read the article

  • What is the JVM Scheduling algorithm ?

    - by IHawk
    Hello ! I am really curious about how does the JVM work with threads ! In my searches in internet, I found some material about RTSJ, but I don't know if it's the right directions for my answers. I also found this topic in sun's forums, http://forums.sun.com/thread.jspa?forumID=513&threadID=472453, but that's not satisfatory. Can someone give me some directions, material, articles or suggestion about the JVM scheduling algorithm ? I am also looking for information about the default configurations of Java threads in the scheduler, like 'how long does it take for every thread' in case of time-slicing. And this stuff. I would appreciate any help ! Thank you !

    Read the article

  • Applet tag error

    - by Yvan JANSSENS
    Hi, I'm getting a FileNotFound error when I try to include my applet. It tries to include a .class file, while I provide a .jar file. Here's the java console output: at java.lang.Thread.run(Thread.java:637) Caused by: java.io.FileNotFoundException: /Users/yvanjanssens/NetBeansProjects/yBlackJack/yBlackJackApplet.class (No such file or directory) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:106) at java.io.FileInputStream.<init>(FileInputStream.java:66) And here's my Applet code: <applet code="yBlackJackApplet" archive="yBlackJack.jar" width="100%" height="100%" > </applet> Thanks! Yvan

    Read the article

  • Why I get different date formats when I run my application through IIS and Visual Studio's web serve

    - by Puneet Dudeja
    I get the same culture i.e. "en-US" while running the website from both IIS and Visual Studio's web server. But I get a different date format as follows, when I run the following code: HttpContext.Current.Response.Write(System.Threading.Thread.CurrentThread.CurrentCulture.ToString()); HttpContext.Current.Response.Write(System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern); On Visual Studio's web server: dd/MM/yyyy en-US On IIS: M/d/yyyy en-US Does "Regional and Language Options" in "Control Panel" play any role in this ? If I change the date format there in "Regional and Language Options", I see no effect in my application.

    Read the article

  • Kohana v3, escape illegal characters?

    - by Dom
    Quick question, does Kohana (version 3) automatically escape data that is passed into ORM::factory..... (and everywhere else that has to do with the database)? For example: $thread = ORM::factory('thread', $this->request->param('id')); Would the data passed in the second argument be auto-escaped before it goes in the SQL query or do I have to manually do it? Probably a stupid question and it's better to be safe than sorry, but yeah... I usually do manually escape the data, but I want to know if Kohana does this for me? Thanks

    Read the article

  • How to get application to use specific version of .NET?

    - by HN
    Hi, I am using pnunit to run nunit tests on remote machines, the pnunit agent loads the test and runs it in Windows 2008 but the test fails to load in Windows 2003, the agent error is INFO PNUnit.Agent.PNUnitAgent - Registering channel on port 9080 INFO PNUnit.Agent.PNUnitAgent - RunTest called for Test MyTest, AssemblyName test.dll, TestToRun test.Program.myDeployTest INFO PNUnit.Agent.PNUnitTestRunner - Spawning a new thread INFO PNUnit.Agent.PNUnitTestRunner - Thread entered for Test MyTest:test.Program.myDeployTest Assembly test.dll Unhandled Exception: System.BadImageFormatException: The format of the file 'test ' is invalid. File name: "test" Server stack trace: at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, B oolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound, Ass embly locationHint, StackCrawlMark& stackMark) On running procmon and monitoring the agent process i could see that the agent executable was using .NET 1.1 assemblies on Windows 2003 and .NET 2.0 on Windows 2008 which could be an explanation for this behavior. How do I get the agent to use .NET 2.0 on Windows 2003?

    Read the article

  • android:black screen switching between activity

    - by 100rabh
    Hi, I am using below code from one of my activity to start another Intent viewIntent = new Intent (getApplicationContext (), landingPage.class); Bundle b = new Bundle (); b.putString ("ApplicationName", a_Bean.getApplicationName ()); if (landingPage.getInstanceCount () < 1) bp.landingPage_ProgressDialog = ProgressDialog.show (ViewAllApp.this, "Please wait...", "Retrieving data...", true, false); viewIntent.putExtras (b); viewIntent.addFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivityForResult (viewIntent,10); Thread background=new Thread(new Runnable() { public void run() { Progresshandler.sendMessage(handler.obtainMessage());//finishes progressDialog }}); background.start (); but after startactivity it shows a black screen & then displays new activity. Can I make progressdialog to be shown while the black screen is displayed??

    Read the article

  • Frame skipping with OpenGL and WinAPI?

    - by user146780
    Here is my situation. I'm creating a drawing application using OpenGL and WinAPI. My OpenGL frame has scrollbars which renders the screen and modifies GlTranslatef when it gets a scroll message. The problem is wen I get too many shapes the scrollbar is less responsive since it cannot rerender it each and every time it gets a scroll message. How could I make it so the scrollbar has priority. I want it to skip drawing if it would compromise the smoothness of the scrolling. I thought of doing rendering on a separate thread but I was told all UI things should stay on the same thread. Thanks

    Read the article

  • Passing arguments to anonymous inner classes

    - by synic
    I'm trying to make an API library for our web services, and I'm wondering if it's possible to do something like this: abstract class UserRequest(val userId: Int) { def success(message: String) def error(error: ApiError) } api.invokeRequest(new UserRequest(121) { override def success(message: String) = { // handle success } override def error(error: ApiError) = { // handle the error } } I'm talking about passing parameters to the anonymous inner class, and also overriding the two methods. I'm extremely new to Scala, and I realize my syntax might be completely wrong. I'm just trying to come up with a good design for this library before I start coding it. I'm willing to take suggestions for this, if I'm doing it the completely wrong way, or if there's a better way. The idea is that the API will take some sort of request object, use it to make a request in a thread via http, and when the response has been made, somehow signal back to the caller if the request was a success or an error. The request/error functions have to be executed on the main thread.

    Read the article

  • Using NSThread to solve waiting for image from URL on the iPhone

    - by james.ingham
    So I have the following code in a method which I want to set a UIImageView image to that of one from an online source: [NSThread detachNewThreadSelector:@selector(loadImage) toTarget:self withObject:nil]; Then in the method called by the thread I have this: - (void) loadImage { NSURL *url = [NSURL URLWithString:logoPath]; // logoPath is an NSString with path details NSData *data = [NSData dataWithContentsOfURL:url]; logoImage.image = [UIImage imageWithData:data]; } This works great however I get many warnings within the Debugger Console along the lines of: 2010-05-10 14:30:14.052 ProjectTitle[2930:633f] * _NSAutoreleaseNoPool(): Object 0x169d30 of class NSHTTPURLResponse autoreleased with no pool in place - just leaking This occurs many times each time I call the new thread and then eventually, under no pattern, after calling a few of these threads I get the classic 'EXC_BAD_ACCESS' run-time error. I understand that this is happening because I'm not retaining the object but how can I solve this with the code in 'loadImage' shown above? Thanks

    Read the article

  • Postgres : Post statement (or insert) asynchronous, non-blocking processing.

    - by Hassan Syed
    I'm wondering if it is possible, that after a collection of rows is inserted, to initiate an operation that is executed asynchronously, is non-blocking, and doesn't need to inform the originator of the request - of the result. I am working with large amounts of events and I can guarantee that the post-insert logic will not fail -- I just want to have a single insert thread in my event-sources, and I want this thread to keep flying without blocking, and without being responsible for any post-delivery book-keeping. I can tell you that I would potentially have a 100 of these jobs executing concurrently and each job might operate on 5 tables with anywhere between 200-1000 inserts on each of these tables. A hint in the right direction should be enough.

    Read the article

  • How can I receive messages using C# over http without MSMQ

    - by pduncan
    I need a reliable messaging framework that runs over http/https (due to client security requirements) and that doesn't use MSMQ (because some clients will use Windows XP Home). The clients only need to be able to receive messages, not send them. We already have a message queue on the server for each user, and the receivers have been getting messages by connecting to an HttpHandler on the server and getting a Stream from WebResponse.GetResponseStream() We keep this stream open, and pull messages off of it using Stream.Read(). This MOSTLY works, but Stream.Read() is a blocking call, and we can't reliably interrupt it. We need to be able to stop and start the receiver without losing messages, but the old stream often hangs around, even after we call Thread.Abort on its thread. Any suggestions?

    Read the article

  • tomcat multithreading problem

    - by jutky
    Hi all I'm writing a java application that runs in Tomcat, on a multi-core hardware. The application executes an algorithm and returns the answer to the user. The problem is that even when I run two requests simultaneously, the tomcat process uses at most one CPU core. As far as I understand each request in Tomcat is executed in separate thread, and JVM should run each thread on separate CPU core. What could be the problem that bounds the JVM or Tomcat to use no more than one core? Thanks in advance.

    Read the article

  • Does my Dictionary must use locking mechanism?

    - by theateist
    Many threads have access to summary. Each thread will have an unique key for accessing the dictionary; Dictionary<string, List<Result>> summary; Do I need locking for following operations? summary[key] = new List<Result>() summary[key].Add(new Result()); It seems that I don't need locking because each thread will access dictionary with different key, but won't the (1) be problematic because of adding concurrently new record to dictionary with other treads?

    Read the article

  • What are some good ways to do intermachine locking?

    - by mike
    Our server cluster consists of 20 machines, each with 10 pids of 5 threads. We'd like some way to prevent any two threads, in any pid, on any machine, from modifying the same object at the same time. Our code's written in Python and runs on Linux, if that helps narrow things down. Also, it's a pretty rare case that two such threads want to do this, so we'd prefer something that optimizes the "only one thread needs this object" case to be really fast, even if it means that the "one thread has locked this object and another one needs it" case isn't great. What are some of the best practices?

    Read the article

  • How can I receive messages over http without MSMQ

    - by pduncan
    I need a reliable messaging framework that runs over http/https (due to client security requirements) and that doesn't use MSMQ (because some clients will use Windows XP Home). The clients only need to be able to receive messages, not send them. We already have a message queue on the server for each user, and the receivers have been getting messages by connecting to an HttpHandler on the server and getting a Stream from WebResponse.GetResponseStream() We keep this stream open, and pull messages off of it using Stream.Read(). This MOSTLY works, but Stream.Read() is a blocking call, and we can't reliably interrupt it. We need to be able to stop and start the receiver without losing messages, but the old stream often hangs around, even after we call Thread.Abort on its thread. Any suggestions?

    Read the article

  • jar dependencies in android- no class definition found exception

    - by Dave.B
    I'm trying to use the gdata java client library on android and have managed a decent hack to get it working. However because the jar for gdata had some package discrepancies with android I had to import the source into my project. This source is dependent on the JavaMail API and the JavaBeans Activation Framework as specified here. My issue is that the JavaMail jar throws a class definition not found when seeking a class which is in the Activation Framework jar. A stack trace is listed below. I am working in Eclipse and have both jars in a lib folder and added to my build path. I'm not very experienced dealing with jars in a situation like this so any help or insight would be appreciated. 03-29 09:55:26.204: ERROR/AndroidRuntime(331): Uncaught handler: thread AsyncTask #3 exiting due to uncaught exception 03-29 09:55:26.215: ERROR/AndroidRuntime(331): java.lang.RuntimeException: An error occured while executing doInBackground() 03-29 09:55:26.215: ERROR/AndroidRuntime(331): at android.os.AsyncTask$3.done(AsyncTask.java:200) 03-29 09:55:26.215: ERROR/AndroidRuntime(331): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273) 03-29 09:55:26.215: ERROR/AndroidRuntime(331): at java.util.concurrent.FutureTask.setException(FutureTask.java:124) 03-29 09:55:26.215: ERROR/AndroidRuntime(331): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307) 03-29 09:55:26.215: ERROR/AndroidRuntime(331): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 03-29 09:55:26.215: ERROR/AndroidRuntime(331): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068) 03-29 09:55:26.215: ERROR/AndroidRuntime(331): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561) 03-29 09:55:26.215: ERROR/AndroidRuntime(331): at java.lang.Thread.run(Thread.java:1096) 03-29 09:55:26.215: ERROR/AndroidRuntime(331): Caused by: java.lang.NoClassDefFoundError: javax.activation.DataHandler 03-29 09:55:26.215: ERROR/AndroidRuntime(331): at javax.mail.internet.MimeBodyPart.setContent(MimeBodyPart.java:684) 03-29 09:55:26.215: ERROR/AndroidRuntime(331): at com.google.gdata.data.media.MediaBodyPart.<init>(MediaBodyPart.java:95) 03-29 09:55:26.215: ERROR/AndroidRuntime(331): at com.google.gdata.data.media.MediaMultipart.<init>(MediaMultipart.java:126) 03-29 09:55:26.215: ERROR/AndroidRuntime(331): at com.google.gdata.client.media.MediaService.insert(MediaService.java:382) 03-29 09:55:26.215: ERROR/AndroidRuntime(331): at android.os.AsyncTask$2.call(AsyncTask.java:185) 03-29 09:55:26.215: ERROR/AndroidRuntime(331): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)

    Read the article

  • Windows 7 UAC elevation

    - by Goz
    I have a single thread that I'd like to run as an administrator in my application. The rest of the application I can happily run as the default user level (asInvoker). Is this possible? I notice there is an "ImpersonateLoggedOnUser" function. Can I somehow use this to log the administrator on and then get the thread to impersonate that person? It seems as though this ought to be something pretty trivial to do ... but there doesn't appear to be any obvious way to do it. Can anyone help me out?

    Read the article

  • Using Core Data Concurrently and Reliably

    - by John Topley
    I'm building my first iOS app, which in theory should be pretty straightforward but I'm having difficulty making it sufficiently bulletproof for me to feel confident submitting it to the App Store. Briefly, the main screen has a table view, upon selecting a row it segues to another table view that displays information relevant for the selected row in a master-detail fashion. The underlying data is retrieved as JSON data from a web service once a day and then cached in a Core Data store. The data previous to that day is deleted to stop the SQLite database file from growing indefinitely. All data persistence operations are performed using Core Data, with an NSFetchedResultsController underpinning the detail table view. The problem I am seeing is that if you switch quickly between the master and detail screens several times whilst fresh data is being retrieved, parsed and saved, the app freezes or crashes completely. There seems to be some sort of race condition, maybe due to Core Data importing data in the background whilst the main thread is trying to perform a fetch, but I'm speculating. I've had trouble capturing any meaningful crash information, usually it's a SIGSEGV deep in the Core Data stack. The table below shows the actual order of events that happen when the detail table view controller is loaded: Main Thread Background Thread viewDidLoad Get JSON data (using AFNetworking) Create child NSManagedObjectContext (MOC) Parse JSON data Insert managed objects in child MOC Save child MOC Post import completion notification Receive import completion notification Save parent MOC Perform fetch and reload table view Delete old managed objects in child MOC Save child MOC Post deletion completion notification Receive deletion completion notification Save parent MOC Once the AFNetworking completion block is triggered when the JSON data has arrived, a nested NSManagedObjectContext is created and passed to an "importer" object that parses the JSON data and saves the objects to the Core Data store. The importer executes using the new performBlock method introduced in iOS 5: NSManagedObjectContext *child = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType]; [child setParentContext:self.managedObjectContext]; [child performBlock:^{ // Create importer instance, passing it the child MOC... }]; The importer object observes its own MOC's NSManagedObjectContextDidSaveNotification and then posts its own notification which is observed by the detail table view controller. When this notification is posted the table view controller performs a save on its own (parent) MOC. I use the same basic pattern with a "deleter" object for deleting the old data after the new data for the day has been imported. This occurs asynchronously after the new data has been fetched by the fetched results controller and the detail table view has been reloaded. One thing I am not doing is observing any merge notifications or locking any of the managed object contexts or the persistent store coordinator. Is this something I should be doing? I'm a bit unsure how to architect this all correctly so would appreciate any advice.

    Read the article

  • Windows Power State change event notification in Qt

    - by Surjya Narayana Padhi
    Hi Geeks, I developing a GUI in QT where I have to show the battery status icon. To get the system power status, I am using the windows API. But to show status anytime , do i need to use a thread to continuously read and display the power status? I am thinking of using event handler. But not sure how to implement. I am thinking that for just one status icon I will run a thread. Anybody has any better suggestion, please share.

    Read the article

< Previous Page | 130 131 132 133 134 135 136 137 138 139 140 141  | Next Page >