Search Results

Search found 9002 results on 361 pages for 'parent child'.

Page 10/361 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Fastest way of creating XML from parent-child table in c#?

    - by rudnev
    Assume we have some DataTable or IEnumerable with ChildID, ParentID and Title. We need to serialize it to XML like <Entity title=""> <Entity title=""></Entity> <Entity title=""></Entity> </Entity> As i found out, standard DataTable.GetXML() returns something different. I thought about initializing class tree like Entity e = new Entity(ID, Title, ParentEntityID) and then serializing it. Table is about 3000 elems. Is there faster way?

    Read the article

  • Calling child constructor by casting (ChildClass)parentObject; to track revisions

    - by FreshCode
    To track revisions of a Page class, I have a PageRevision class which inherits from Page and adds a revision ID (Guid RevisionID;). If possible, how should I cast an existing Page object to a PageRevision and ensure that the PageRevision constructor is called to create a new revision ID? I could could have a PageRevision(Page page) constructor which generates the Guid and copies all the Page attributes, but I want to automate it, especially if a Page class has many attributes (and I later add one, and forget to modify the copy constructor). Desired use Page page = new Page(123, "Page Title", "Page Body"); // where 123 is page ID PageRevision revision = (PageRevision)page; // now revision.RevisionID should be a new Guid. Page, PageRevision classes: public class Page { public int ID { get; set; } public string Title { get; set; } public string Body { get; set; } } public class PageRevision : Page { public Guid RevisionID { get; set; } public PageRevision() { this.RevisionID = Guid.NewGuid(); } }

    Read the article

  • What happens to a SIGINT (^C) when sent to a perl script containing children?

    - by CmdrGuard
    I have a Perl script that forks. Each fork runs an external program, parses the output, and converts the output to a Storable file. The Storable files are then read in by the parent and the total data from each of the children are analyzed before proceeding onto a repeat of the previous fork or else the parent stops. What exactly happens when I issue a ^C while some of the children are still running the external program? The parent perl script was called in the foreground and, I presume, remained in the foreground despite the forking. Is the SIGINT passed to all children, that is, the parent, the parent's children, and the external program called by the children??

    Read the article

  • Ubuntu 12.04 LTS: Error message "Failed to execute child process"

    - by Ron
    I am an Ubuntu-newbie and just started working with Ubuntu (version 12.04 LTS) a couple of days ago. I wanted to add a launcher icon to desktop for launching an application I previously installed. Up to now I can only launch it by typing setsid matlab -desktop into my terminal. Now there is the following problem with the execution via the desktop icon: Whenever I click the desktop icon, I get the following error message: "Failed to execute child process" I would like to add a screenshot, but unfortunately as a new user, I am not allowed to... In the main menu from where I added the icon via drag'n'drop to desktop there is also a permission to execute the .desktop file. I also tried to look for advice on the error message "Failed to execute child process..." but could not find anything useful. Now does anybody have an idea what I am missing? Sorry if this is a stupid question ;) ...but as I just said: I just started with Ubuntu... Thanks to everybody in advance for their help! :) And let me know if you should need any more information... Regards, Ron

    Read the article

  • Best practice to collect information from child objects

    - by Markus
    I'm regularly seeing the following pattern: public abstract class BaseItem { BaseItem[] children; // ... public void DoSomethingWithStuff() { StuffCollection collection = new StuffCollection(); foreach(child c : children) c.AddRequiredStuff(collection); // do something with the collection ... } public abstract void AddRequiredStuff(StuffCollection collection); } public class ConcreteItem : BaseItem { // ... public override void AddRequiredStuff(StuffCollection collection) { Stuff stuff; // ... collection.Add(stuff); } } Where I would use something like this, for better information hiding: public abstract class BaseItem { BaseItem[] children; // ... public void DoSomethingWithStuff() { StuffCollection collection = new StuffCollection(); foreach(child c : children) collection.AddRange(c.RequiredStuff()); // do something with the collection ... } public abstract StuffCollection RequiredStuff(); } public class ConcreteItem : BaseItem { // ... public override StuffCollection RequiredStuff() { StuffCollection stuffCollection; Stuff stuff; // ... stuffCollection.Add(stuff); return stuffCollection; } } What are pros and cons of each solution? For me, giving the implementation access to parent's information is some how disconcerting. On the other hand, initializing a new list, just to collect the items is a useless overhead ... What is the better design? How would it change, if DoSomethingWithStuff wouldn't be part of BaseItem but a third class? PS: there might be missing semicolons, or typos; sorry for that! The above code is not meant to be executed, but just for illustration.

    Read the article

  • outer join for parent child chain

    - by dotnetcoder
    Considering below tables and relationships: parent --1:Many-- children --1:Many-- shubchildren Parent may or many not have children records. children always have subchildren records. I wan to write a qiery to select parent names where any if matched parent.name,children.name or subchildren.name Here i understand I have to do a left outer join between parent and children. But what kind of join should I put between children and subchildren ?

    Read the article

  • Prevent an Activity from being killed by the OS while starting a child activity

    - by Martin Marinov
    I have a main activity which calls a child one via Intent I = new Intent(this, Child.class); startActivityForResult(I, 0); But as soon as Child becomes visible the main activity gets its onStop and immediately after that onDestroy method triggered. And as soon as I call finish() within the Child activity or press the back button, the Child activity closes and the home screen shows (instead of the main activity). How can I prevent the main activity from being destroyed? :\

    Read the article

  • Why SQL2008 debugger would NOT step into a certain child stored procedure

    - by John Galt
    I'm encountering differences in T-SQL with SQL2008 (vs. SQL2000) that are leading me to dead-ends. I've verified that the technique of sharing #TEMP tables between a caller which CREATES the #TEMP and the child sProc which references it remain valid in SQL2008 See recent SO question. My core problem remains a critical "child" stored procedure that works fine in SQL2000 but fails in SQL2008 (i.e. a FROM clause in the child sProc is coded as: SELECT * FROM #AREAS A) despite #AREAS being created by the calling parent. Rather than post snippets of the code now, here is another symptom that may help you suggest something. I fired up the new debugger in SQL Mgmt Studio: EXEC dbo.AMS1 @S1='06',@C1='037',@StartDate='01/01/2008',@EndDate='07/31/2008',@Type=1,@ACReq = 1,@Output = 0,@NumofLines = 30,@SourceTable = 'P',@LoanPurposeCatg='P' This is a very large sProc and the key snippet that is weird is the following: **create table #Areas ( State char(2) , County char(3) , ZipCode char(5) NULL , CityName varchar(28) NULL , PData varchar(3) NULL , RData varchar(3) NULL , SMSA_CD varchar(10) NULL , TypeCounty varchar(50) , StateAbbr char(2) ) EXECUTE dbo.AMS_I_GetAreasV5 -- this child populates #Areas @SMSA = @SMSA , @S1 = @S1 , @C1 = @C1 , @Z1 = @Z1 , @SourceTable = @SourceTable , @CustomID = @CustomID , @UserName = @UserName , @CityName = @CityName , @Debug=0 EXECUTE dbo.AMS_I_GetAreas_FixAC -- this child cannot reference #Areas @StartDate = @StartDate , @EndDate = @EndDate , @SMSA_CD = @SMSA_CD , @S1 = @S1 , @C1 = @C1 , @Z1 = @Z1 , @CityName = @CityName , @CustomID = @CustomID , @Debug=0 -- continuation of the parent sProc** I can step through the execution of the parent stored procedure. When I get to the first child sproc above, I can either STEP INTO dbo.AMS_I_GetAreasV5 or STEP OVER its execution. When I arrive at the invocation of the 2nd child sProc - dbo.AMS_I_GetAreas_FixAC - I try to STEP INTO it (because that is where the problem statement is) and STEP INTO is ignored (i.e. treated like STEP OVER instead; yet I KNOW I pressed F11 not F10). It WAS executed however, because when control is returned to the statement after the EXECUTE, I click Continue to finish execution and the results windows shows the errors in the dbo.AMS_I_GetAreas_FixAC (i.e. the 2nd child) stored procedure. Is there a way to "pre-load" an sProc with the goal of setting a breakpoint on its entry so that I can pursue execution inside it? In summary, I wonder if the inability to step into a given child sproc might be related to the same inability of this particular child to reference a #temp created by its parent (caller).

    Read the article

  • Window parent not working in IE 8

    - by archana roy
    I have a parent page and a child page. By using window.opener.parent property,I am able to read the parent page content and display it in the child page.(There is a PREVIEW button on parent page,on click of which the child page opens up as a popup and displays the content of parent page controls.) This functionality was working fine in IE7/Mozilla/IE6 but I am unable to locate why its not workin with IE8. Can anyone please help?

    Read the article

  • How to delete child table records during the update of parent table using Hibernate

    - by Harsha
    I have a Parent Table A and child tables B,C with many to one relations. Lets say I have data like, for primary key 1 in parent table A I have 3 rows in child table B and 4 rows in child table C. Now if I want to delete the rows of the child table during an update of the parent table(that means Now, I want to update the table only with one row in each child tables and delete the other rows in them) then how to handle this scenario in hibernate?

    Read the article

  • Deleting an XML tag using C#

    - by gsvirdi
    FIRST EDIT I'm fetching the Child 1 tag into a DropDownList in my C# form, Plz suggest the best practise code (C#) for deleting a Particular Parent tag & all it's child tags in an XML file. Example of my xml file: <Parents> <Parent> <Child 1>Something</Child 1> <Child 2>Something</Child 2> <Child 3>Something</Child 3> <Child 4>Something</Child 4> </Parent> <Parent> <Child 1>Something 1</Child 1> <Child 2>Something 1</Child 2> <Child 3>Something 1</Child 3> <Child 4>Something 1</Child 4> </Parent> </Parents> I mean something like: for (int i=0; i<[Length of xml doc]; i++) { if (Child 1 == ComboBox1.Text && Child 2 == richTextBox1.Text) // Delete <Parent> tag of that Child 1 }

    Read the article

  • Help me re-center a ModalPopup within an iframe when the iframe's parent window scrolls

    - by Cory Larson
    I have a web page with an iframe in it (I don't like it, but that's the way it has to be). It's not a cross-domain iframe so there's nothing to worry about there. I have written a jQuery extension that does the centering of a ModalPopup (which is called from an overridden AjaxControlToolkit.ModalPopupBehavior._layout method) based on the width and height of the iframe's parent, so that it looks centered even though the iframe is not in the center of the page. It's a lot of tricky stuff, especially since the web page I added the iframe to runs in quirks mode. Now, I've also overridden AjaxControlToolkit.ModalPopupBehavior._attachPopup, so that when the parent window resizes or scrolls, the ModalPopup inside of the iframe recenter's itself relative to the new size of the parent window. However, the same code that attaches the popup to the parent window's resize event does NOT work for the parent window's scroll event. See the code below, and the comments: AjaxControlToolkit.ModalPopupBehavior.prototype._attachPopup = function() { /// <summary> /// Attach the event handlers for the popup to the PARENT window /// </summary> if (this._DropShadow && !this._dropShadowBehavior) { this._dropShadowBehavior = $create(AjaxControlToolkit.DropShadowBehavior, {}, null, null, this._popupElement); } if (this._dragHandleElement && !this._dragBehavior) { this._dragBehavior = $create(AjaxControlToolkit.FloatingBehavior, {"handle" : this._dragHandleElement}, null, null, this._foregroundElement); } $addHandler(parent.window, 'resize', this._resizeHandler); // <== This WORKS $addHandler(parent.window, 'scroll', this._scrollHandler); // <== This DOES NOT work this._windowHandlersAttached = true; } Can anybody explain to me why the resize event works while the scroll event doesn't? Any suggestions or alternatives out there to help me out? I am working with jQuery, so if I can use something besides the $addHandler method from MS that'd be fine. Be aware that I also have to override the _detachPopup function to remove the handler, so I need to take that into account. Thanks!

    Read the article

  • Child Activity in Android

    - by Martin Marinov
    So I have two Activities. The main is called Main, and the child one is called Child. When a button is clicked in the main activity it triggers the following piece of code: Intent i = new Intent(Main.this, Child.class); Main.this.startActivity(i); That opens the Child activity. As soon as I call finish() or press the back button within the child activity instead of going back to the main one, the app just closes. Can you give me a hint where the problem might be :( P.S. By trial and error I found out that if edit AndroidManifest.xml and add android:theme="@android:style/Theme.Dialog" within the declaration of Child the back button and calling finish() behaves as expected: closes the child activity and brings the main into focus. The problem is that when I start typing in an EditText the screen starts flickering (rather bizzare). So I can't use it as a dialog. My main activity uses the camera, so that might be making problems. Although when the child activity is started, the onPause event is fired and it stops the camera until onResume is called.

    Read the article

  • Partial overriding in Java (or dynamic overriding while overloading)

    - by Lie Ryan
    If I have a parent-child that defines some method .foo() like this: class Parent { public void foo(Parent arg) { System.out.println("foo in Function"); } } class Child extends Parent { public void foo(Child arg) { System.out.println("foo in ChildFunction"); } } When I called them like this: Child f = new Child(); Parent g = f; f.foo(new Parent()); f.foo(new Child()); g.foo(new Parent()); g.foo(new Child()); the output is: foo in Parent foo in Child foo in Parent foo in Parent But, I want this output: foo in Parent foo in Child foo in Parent foo in Child I have a Child class that extends Parent class. In the Child class, I want to "partially override" the Parent's foo(), that is, if the argument arg's type is Child then Child's foo() is called instead of Parent's foo(). That works Ok when I called f.foo(...) as a Child; but if I refer to it from its Parent alias like in g.foo(...) then the Parent's foo(..) get called irrespective of the type of arg. As I understand it, what I'm expecting doesn't happen because method overloading in Java is early binding (i.e. resolved statically at compile time) while method overriding is late binding (i.e. resolved dynamically at compile time) and since I defined a function with a technically different argument type, I'm technically overloading the Parent's class definition with a distinct definition, not overriding it. But what I want to do is conceptually "partially overriding" when .foo()'s argument is a subclass of the parent's foo()'s argument. I know I can define a bucket override foo(Parent arg) in Child that checks whether arg's actual type is Parent or Child and pass it properly, but if I have twenty Child, that would be lots of duplication of type-unsafe code. In my actual code, Parent is an abstract class named "Function" that simply throws NotImplementedException(). The children includes "Polynomial", "Logarithmic", etc and .foo() includes things like Child.add(Child), Child.intersectionsWith(Child), etc. Not all combination of Child.foo(OtherChild) are solvable and in fact not even all Child.foo(Child) is solvable. So I'm best left with defining everything undefined (i.e. throwing NotImplementedException) then defines only those that can be defined. So the question is: Is there any way to override only part the parent's foo()? Or is there a better way to do what I want to do?

    Read the article

  • how can i check all ul of nested checkboxes

    - by Mike
    Question: I have a category listing which some categories have children, I am trying to create a ALL category that when clicked, will check all sibling checkboxes in that same category. e.g; clicking ALL underneath the MUSIC category would check blues, jazz, rock n roll Code: HTML: <ul name="events-categories" id="events-categories"> <li><input type="checkbox" name="category-events" value="185" placeholder="" id="category-185" class="events-category"> CONVENTIONS <ul class="event-children"> <li><input type="checkbox" name="child-category-all" value="" class="events-child-category-all">ALL</li> <li><input type="checkbox" name="child-category-190" value="190" id="child-category-190" class="child events-child-category">SCIENCE</li> <li><input type="checkbox" name="child-category-191" value="191" id="child-category-191" class="child events-child-category">TECHNOLOGY</li> </ul> </li> <li><input type="checkbox" name="category-events" value="184" placeholder="" id="category-184" class="events-category"> MUSIC <ul class="event-children"> <li><input type="checkbox" name="child-category-all" value="" class="events-child-category-all">ALL</li> <li><input type="checkbox" name="child-category-189" value="189" id="child-category-189" class="child events-child-category">BLUES</li> <li><input type="checkbox" name="child-category-188" value="188" id="child-category-188" class="child events-child-category">JAZZ</li> <li><input type="checkbox" name="child-category-187" value="187" id="child-category-187" class="child events-child-category">ROCK N ROLL</li> </ul> </li> <li><input type="checkbox" name="category-events" value="186" placeholder="" id="category-186" class="events-category"> TRIBUTES</li> </ul>? CSS: .event-children { margin-left: 20px; list-style: none; display: none; }? jQuery So Far: /** * left sidebar events categories * toggle sub categories */ $('.events-category').change( function(){ console.log('showing sub categories'); var c = this.checked; if( c ){ $(this).next('.event-children').css('display', 'block'); }else{ $(this).next('.event-children').css('display', 'none'); } }); $('.events-child-category-all').change( function(){ var c = this.checked; if( c ){ $(this).siblings(':checkbox').attr('checked',true); }else{ $(this).siblings(':checkbox').attr('checked',false); } });? jsfiddle: http://jsfiddle.net/SENV8/

    Read the article

  • Multithreading: Communication from Parent thread to child thread

    - by Dennis Nowland
    I have a List of threads normally 3 threads each of the threads reference a webbrowser control that communicates with the parent control to populate a datagridview. What I need to do is when the user clicks the button in a datagridviewButtonCell corresponding data will be sent back to the webbrowser control within the child thread that originally communicated with the main thread. but when I try to do this I receive the following error message 'COM object that has been separated from its underlying RCW cannot be used.' my problem is that I can not figure out how to reference the relevant webbrowser control. I would appreciate any help that anyone can give me. The language used is c# winforms .Net 4.0 targeted Code sample: The following code is executed when user click on the Start button in the main thread private void StartSubmit(object idx) { /* method used by the new thread to initialise a 'myBrowser' inherited from the webbrowser control each submitters object is an a custom Control called 'myBrowser' which holds detail about the function of the object eg: */ //index: is an integer value which represents the threads id int index = (int)idx; //submitters[index] is an instance of the 'myBrowser' control submitters[index] = new myBrowser(); //threads integer id submitters[index]._ThreadNum = index; // naming convention used 'browser' +the thread index submitters[index].Name = "browser" + index; //set list in 'myBrowser' class to hold a copy of the list found in the main thread submitters[index]._dirs = dirLists[index]; // suppress and javascript errors the may occur in the 'myBrowser' control submitters[index].ScriptErrorsSuppressed = true; //execute eventHandler submitters[index].DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(DocumentCompleted); //advance to the next un-opened address in datagridview the navigate the that address //in the 'myBrowser' control. SetNextDir(submitters[index]); } private void btnStart_Click(object sender, EventArgs e) { // used to fill list<string> for use in each thread. fillDirs(); //connections is the list<Thread> holding the thread that have been opened //1 to 10 maximum for (int n = 0; n < (connections.Length); n++) { //initialise new thread to the StartSubmit method passing parameters connections[n] = new Thread(new ParameterizedThreadStart(StartSubmit)); // naming convention used conn + the threadIndex ie: 'conn1' to 'conn10' connections[n].Name = "conn" + n.ToString(); // due to the webbrowser control needing to be ran in the single //apartment state connections[n].SetApartmentState(ApartmentState.STA); //start thread passing the threadIndex connections[n].Start(n); } } Once the 'myBrowser' control is fully loaded I am inserting form data into webforms found in webpages loaded via data enter into rows found in the datagridview. Once a user has entered the relevant details into the different areas in the row the can then clicking a DataGridViewButtonCell that has tha collects the data entered and then has to be send back to the corresponding 'myBrowser' object that is found on a child thread. Thank you

    Read the article

  • how to update child records when updating the Master table using Linq [closed]

    - by user20358
    I currently use a general repositry class that can update only a single table like so public abstract class MyRepository<T> : IRepository<T> where T : class { protected IObjectSet<T> _objectSet; protected ObjectContext _context; public MyRepository(ObjectContext Context) { _objectSet = Context.CreateObjectSet<T>(); _context = Context; } public IQueryable<T> GetAll() { return _objectSet.AsQueryable(); } public IQueryable<T> Find(Expression<Func<T, bool>> filter) { return _objectSet.Where(filter); } public void Add(T entity) { _objectSet.AddObject(entity); _context.ObjectStateManager.ChangeObjectState(entity, System.Data.EntityState.Added); _context.SaveChanges(); } public void Update(T entity) { _context.ObjectStateManager.ChangeObjectState(entity, System.Data.EntityState.Modified); _context.SaveChanges(); } public void Delete(T entity) { _objectSet.Attach(entity); _context.ObjectStateManager.ChangeObjectState(entity, System.Data.EntityState.Deleted); _objectSet.DeleteObject(entity); _context.SaveChanges(); } } For every table class generated by my EDMX designer I create another class like this public class CustomerRepo : MyRepository<Customer> { public CustomerRepo (ObjectContext context) : base(context) { } } for any updates that I need to make to a particular table I do this: Customer CustomerObj = new Customer(); CustomerObj.Prop1 = ... CustomerObj.Prop2 = ... CustomerObj.Prop3 = ... CustomerRepo.Update(CustomerObj); This works perfectly well when I am updating just to the specific table called Customer. Now if I need to also update each row of another table which is a child of Customer called Orders what changes do I need to make to the class MyRepository. Orders table will have multiple records for a Customer record and multiple fields too, say for example Field1, Field2, Field3. So my questions are: 1.) If I only need to update Field1 of the Orders table for some rows based on a condition and Field2 for some other rows based on a different condition then what changes I need to do? 2.) If there is no such condition and all child rows need to be updated with the same value for all rows then what changes do I need to do? Thanks for taking the time. Look forward to your inputs...

    Read the article

  • NHibernate tutorial #6 - Parent-Child Relationships

    - by BobPalmer
    I've finally had a chance to continue my NHibernate tutorial series after a series of vacations and events.  In this tutorial, I cover one of the most common relationships, that of the parent-child, in NHibernate.  I also go through some optimization refactoring along the way. You can view the entire Google Docs article here: http://docs.google.com/Doc?docid=0AUP-rKyyUMKhZGczejdxeHZfMzBmdjdzZDlkaA&hl=en   As always, feedback is appreciate! -Bob

    Read the article

  • Parent-child hierarchies and unary operators in PowerPivot

    - by Marco Russo (SQLBI)
    Alberto wrote an excellent post describing how to implement the Unary Operator feature (which is present in Analysis Services) in PowerPivot (there was a previous post about parent-child hierarchies, too). I have to say that the solution is not so easy to implement as in Analysis Services, but it just works and, from a practical point of view, it is not so difficult to implement if you understand how it works and accept its limitations (only sum and subtractions are supported). I think that many...(read more)

    Read the article

  • How to use pthread_atfork() and pthread_once() to reinitialize mutexes in child processes

    - by Blair Zajac
    We have a C++ shared library that uses ZeroC's Ice library for RPC and unless we shut down Ice's runtime, we've observed child processes hanging on random mutexes. The Ice runtime starts threads, has many internal mutexes and keeps open file descriptors to servers. Additionally, we have a few of mutexes of our own to protect our internal state. Our shared library is used by hundreds of internal applications so we don't have control over when the process calls fork(), so we need a way to safely shutdown Ice and lock our mutexes while the process forks. Reading the POSIX standard on pthread_atfork() on handling mutexes and internal state: Alternatively, some libraries might have been able to supply just a child routine that reinitializes the mutexes in the library and all associated states to some known value (for example, what it was when the image was originally executed). This approach is not possible, though, because implementations are allowed to fail *_init() and *_destroy() calls for mutexes and locks if the mutex or lock is still locked. In this case, the child routine is not able to reinitialize the mutexes and locks. On Linux, the this test C program returns EPERM from pthread_mutex_unlock() in the child pthread_atfork() handler. Linux requires adding _NP to the PTHREAD_MUTEX_ERRORCHECK macro for it to compile. This program is linked from this good thread. Given that it's technically not safe or legal to unlock or destroy a mutex in the child, I'm thinking it's better to have pointers to mutexes and then have the child make new pthread_mutex_t on the heap and leave the parent's mutexes alone, thereby having a small memory leak. The only issue is how to reinitialize the state of the library and I'm thinking of reseting a pthread_once_t. Maybe because POSIX has an initializer for pthread_once_t that it can be reset to its initial state. #include <pthread.h> #include <stdlib.h> #include <string.h> static pthread_once_t once_control = PTHREAD_ONCE_INIT; static pthread_mutex_t *mutex_ptr = 0; static void setup_new_mutex() { mutex_ptr = malloc(sizeof(*mutex_ptr)); pthread_mutex_init(mutex_ptr, 0); } static void prepare() { pthread_mutex_lock(mutex_ptr); } static void parent() { pthread_mutex_unlock(mutex_ptr); } static void child() { // Reset the once control. pthread_once_t once = PTHREAD_ONCE_INIT; memcpy(&once_control, &once, sizeof(once_control)); setup_new_mutex(); } static void init() { setup_new_mutex(); pthread_atfork(&prepare, &parent, &child); } int my_library_call(int arg) { pthread_once(&once_control, &init); pthread_mutex_lock(mutex_ptr); // Do something here that requires the lock. int result = 2*arg; pthread_mutex_unlock(mutex_ptr); return result; } In the above sample in the child() I only reset the pthread_once_t by making a copy of a fresh pthread_once_t initialized with PTHREAD_ONCE_INIT. A new pthread_mutex_t is only created when the library function is invoked in the child process. This is hacky but maybe the best way of dealing with this skirting the standards. If the pthread_once_t contains a mutex then the system must have a way of initializing it from its PTHREAD_ONCE_INIT state. If it contains a pointer to a mutex allocated on the heap than it'll be forced to allocate a new one and set the address in the pthread_once_t. I'm hoping it doesn't use the address of the pthread_once_t for anything special which would defeat this. Searching comp.programming.threads group for pthread_atfork() shows a lot of good discussion and how little the POSIX standards really provides to solve this problem. There's also the issue that one should only call async-signal-safe functions from pthread_atfork() handlers, and it appears the most important one is the child handler, where only a memcpy() is done. Does this work? Is there a better way of dealing with the requirements of our shared library?

    Read the article

  • Javascript parent and child window functions

    - by Mike Thornley
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>Lab 9-3</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!-- function myFunction(){ myWin = open("","","width=200,height=200"); with(myWin.document){ open(); write("<HTML><HEAD><TITLE>Child Window</TITLE>"); write("<SCRIPT>function myTest(){"); write("alert('This function is defined in the child window "); write("and is called from the parent window.'); this.focus();}"); write("</SCRIPT></HEAD><BODY><H3>Child Window</H3><HR>"); write("<FORM><INPUT TYPE='button' VALUE='parent window function' "); // Use opener property write("onClick='opener.winFunction();'>"); write("<P><INPUT TYPE='button' VALUE='close window' "); write("onClick='window.close();'>"); write("</FORM></BODY></HTML>"); close(); } } function winFunction(){ alert("This function is defined in the parent window\n" + "and is called from the child window."); myWin.focus(); } //--> </SCRIPT> </HEAD> <BODY> <H3>CIW Web Languages</H3> <HR> <FORM NAME="myForm"> <INPUT TYPE="button" VALUE="open new window" onClick="myFunction();"> <!-- Invoke child window function --> <input type="button" value="Click to open child window" onclick="javascript:void(myWin.myTest());"/> </FORM> <P> </BODY> </HTML> To explain further what my initial query was, the code above, should open the child window (myWin) with the second button, the 'Open child window' button without the need to open the window with the first button or do anything else. It should simply call the myWin.myTest()function The child window will open when the second button is pressed but needs to have the child window open first (first button push) before it'll work. This is not the intended purpose, the 'Open child window' button should work without anything else needing to be done. For some reason the parent window isn't communicating with the myWin window and myTest fucntion. It's not homework, it's part of a certification course lab and is coded in the manner I have been shown to understand as correct. DTD isn't included as the focus is the JavaScript. I code correctly with regards to that and other W3C requirements.

    Read the article

  • SQL Query to update parent record with child record values

    - by Wells
    I need to create a Trigger that fires when a child record (Codes) is added, updated or deleted. The Trigger stuffs a string of comma separated Code values from all child records (Codes) into a single field in the parent record (Projects) of the added, updated or deleted child record. I am stuck on writing a correct query to retrieve the Code values from just those child records that are the children of a single parent record. -- Create the test tables CREATE TABLE projects ( ProjectId varchar(16) PRIMARY KEY, ProjectName varchar(100), Codestring nvarchar(100) ) GO CREATE TABLE prcodes ( CodeId varchar(16) PRIMARY KEY, Code varchar (4), ProjectId varchar(16) ) GO -- Add sample data to tables: Two projects records, one with 3 child records, the other with 2. INSERT INTO projects (ProjectId, ProjectName) SELECT '101','Smith' UNION ALL SELECT '102','Jones' GO INSERT INTO prcodes (CodeId, Code, ProjectId) SELECT 'A1','Blue', '101' UNION ALL SELECT 'A2','Pink', '101' UNION ALL SELECT 'A3','Gray', '101' UNION ALL SELECT 'A4','Blue', '102' UNION ALL SELECT 'A5','Gray', '102' GO I am stuck on how to create a correct Update query. Can you help fix this query? -- Partially working, but stuffs all values, not just values from chile (prcodes) records of parent (projects) UPDATE proj SET proj.Codestring = (SELECT STUFF((SELECT ',' + prc.Code FROM projects proj INNER JOIN prcodes prc ON proj.ProjectId = prc.ProjectId ORDER BY 1 ASC FOR XML PATH('')),1, 1, '')) The result I get for the Codestring field in Projects is: ProjectId ProjectName Codestring 101 Smith Blue,Blue,Gray,Gray,Pink ... But the result I need for the Codestring field in Projects is: ProjectId ProjectName Codestring 101 Smith Blue,Pink,Gray ... Here is my start on the Trigger. The Update query, above, will be added to this Trigger. Can you help me complete the Trigger creation query? CREATE TRIGGER Update_Codestring ON prcodes AFTER INSERT, UPDATE, DELETE AS WITH CTE AS ( select ProjectId from inserted union select ProjectId from deleted )

    Read the article

  • How to set path of Virtual PC hard disk differencing parent

    - by Barry Kelly
    I have an old Windows XP Mode vhd backed up from my previous system, but I'm having difficulty getting it running on the new system. The vhd is a differencing disk, and its parent is the standard Windows XP Mode base; I still have the old parent, and have verified it is binary identical to the XP Mode base in my new installation of XP Mode. But in the new system, the path to the differencing disk parent is different than the old. When I open up the settings for the .vmcx for my old XP mode, and select "Hard Disk 1", the "Virtual hard disk file" is set correctly, but the "Parent Disk:" field is pointing at the wrong path, and I can't see any way to edit it. Does anyone know how?

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >