Search Results

Search found 19688 results on 788 pages for 'con current'.

Page 81/788 | < Previous Page | 77 78 79 80 81 82 83 84 85 86 87 88  | Next Page >

  • Sync a WinForm with DatagridView

    - by Ruben Trancoso
    I have a Form with a DataGridView which DataSource is a BindingSource to a table. This view will have a single row selection and a button to delete, edit the current selected row in a popup Form and a insert button that will use the same Form as well. My question is how can I sync the pop Form with the current row? I tryied to use the RowStateChanged event to get and store the current selected Row to be used in the Form but I coudnt. After the event I get the row that was selected before. Other thing I dont understand yet in C# how to have a single recordSet and know wich is the current record even if its a new being inserted in a way that once in the Form all data being entered will show up at the same time in the DataGridView.

    Read the article

  • Not Getting Profile properties in Code Behind.

    - by user228777
    I am trying to get Profile properties in the code behind. But I am not getting any intellisence like Profile.Homephone or Profile.CellPhone. When I try Dim memberprofile As ProfileBase = HttpContext.Current.Profile Dim homePhone As String = memberprofile.GetPropertyValue("HomePhone").ToString() I get Data is Null. This method or property cannot be called on Null values error. I have data for current user in the profile Table. I get following results in immediate window ?HttpContext.Current.Profile.UserName.ToString "sub2" ?Profile.DefaultProfile.Properties.Count 2 ? HttpContext.Current.Profile("HomePhone") "" {String} String: "" I am not able to run property values in page load event. This is my web.config file setting.

    Read the article

  • CLLocation is not nil but trying to print it out throws EXC_BAD_ACCESS

    - by nefsu
    Sorry, this may be a noob question but I'm working with CoreLocation and this has be stumped. I'm looking up the currentLocation using a singleton that was recommended on this site and when I get the currentLocation object, it returns true to a not nil check. However, when I try to print out its description, it throws EXC_BAD_ACCESS. //WORKS Current location 8.6602e-290 NSLog(@"Current location %g",currLoc); //DOESN'T WORK NSLog(@"Current location %@",[currLoc description]); //DOESN'T WORK - Is this causing the description to fail as well? NSLog(@"Current location %g",currLoc.coordinate.latitude); Why am I able to see something on the first one but not the others? BTW, this is being run on a 3.1.2 simulator Thanks.

    Read the article

  • Pair-wise iteration in C# or sliding window enumerator

    - by f3lix
    If I have an IEnumerable like: string[] items = new string[] { "a", "b", "c", "d" }; I would like to loop thru all the pairs of consecutive items (sliding window of size 2). Which would be ("a","b"), ("b", "c"), ("c", "d") My solution was is this public static IEnumerable<Pair<T, T>> Pairs(IEnumerable<T> enumerable) { IEnumerator<T> e = enumerable.GetEnumerator(); e.MoveNext(); T current = e.Current; while ( e.MoveNext() ) { T next = e.Current; yield return new Pair<T, T>(current, next); current = next; } } // used like this : foreach (Pair<String,String> pair in IterTools<String>.Pairs(items)) { System.Out.PrintLine("{0}, {1}", pair.First, pair.Second) } When I wrote this code, I wondered if there are already functions in the .NET framework that do the same thing and do it not just for pairs but for any size tuples. IMHO there should be a nice way to do this kind of sliding window operations. I use C# 2.0 and I can imagine that with C# 3.0 (w/ LINQ) there are more (and nicer) ways to do this, but I'm primarily interested in C# 2.0 solutions. Though, I will also appreciate C# 3.0 solutions.

    Read the article

  • Draw LINE_STRIP with Unity

    - by Boozzz
    For a new project I am thinking about whether to use OpenGL or Unity3d. I have a bit of experience with OpenGL, but I am completely new to Unity. I already read through the Unity documentation and tutorials on the Unity Website. However, I could not find a way to draw a simple Line-Strip with Unity. In the following example (C#, OpenGL/SharpGL) I draw a round trajectory from a predifined point to an obstacle, which can be imagined as a divided circle with midpoint [cx,cy] and radius r. The position (x-y coordinates) of the obstacle is given by obst_x and obst_y. Question 1: How could I do the same with Unity? Question 2: In my new project, I will have to draw quite a lot of such geometric primitives. Does it make any sense to use Unity for those things? void drawCircle(float cx, float cy, float r, const float obst_x, const float obst_y) { float theta = 0.0f, pos_x, pos_y, dist; const float delta = 0.1; glBegin(GL_LINE_STRIP); while (theta < 180) { theta += delta; //get the current angle float x = r * cosf(theta); //calculate the x component float y = r * sinf(theta); //calculate the y component pos_x = x + cx; //calculate current x position pos_y = y + cy; //calculate current y position //calculate distance from current vertex to obstacle dist = sqrt(pow(pos_x - obst_x) + pow(pos_y - obst_y)); //check if current vertex intersects with obstacle if dist <= 0 { break; //stop drawing circle } else { glVertex2f(pos_x, pos_y); //draw vertex } } glEnd(); }

    Read the article

  • Throwing exception vs returning null value with switch statement

    - by Greg
    So I have function that formats a date to coerce to given enum DateType{CURRENT, START, END} what would be the best way to handling return value with cases that use switch statement public static String format(Date date, DateType datetype) { ..validation checks switch(datetype){ case CURRENT:{ return getFormattedDate(date, "yyyy-MM-dd hh:mm:ss"); } ... default:throw new ("Something strange happend"); } } OR throw excpetion at the end public static String format(Date date, DateType datetype) { ..validation checks switch(datetype){ case CURRENT:{ return getFormattedDate(date, "yyyy-MM-dd hh:mm:ss"); } ... } //It will never reach here, just to make compiler happy throw new IllegalArgumentException("Something strange happend"); } OR return null public static String format(Date date, DateType datetype) { ..validation checks switch(datetype){ case CURRENT:{ return getFormattedDate(date, "yyyy-MM-dd hh:mm:ss"); } ... } return null; } What would be the best practice here ? Also all the enum values will be handled in the case statement

    Read the article

  • Can I constrain a template parameter class to implement the interfaces that are supported by other?

    - by K. Georgiev
    The name is a little blurry, so here's the situation: I'm writing code to use some 'trajectories'. The trajectories are an abstract thing, so I describe them with different interfaces. So I have a code as this: namespace Trajectories { public interface IInitial < Atom > { Atom Initial { get; set; } } public interface ICurrent < Atom > { Atom Current { get; set; } } public interface IPrevious < Atom > { Atom Previous { get; set; } } public interface ICount < Atom > { int Count { get; } } public interface IManualCount < Atom > : ICount < Atom > { int Count { get; set; } } ... } Every concrete implementation of a trajectory will implement some of the above interfaces. Here's a concrete implementation of a trajectory: public class SimpleTrajectory < Atom > : IInitial < Atom >, ICurrent < Atom >, ICount < Atom > { // ICount public int Count { get; private set; } // IInitial private Atom initial; public Atom Initial { get { return initial; } set { initial = current = value; Count = 1; } } // ICurrent private Atom current; public Atom Current { get { return current; } set { current = value; Count++; } } } Now, I want to be able to deduce things about the trajectories, so, for example I want to support predicates about different properties of some trajectory: namespace Conditions { public interface ICondition &lt Atom, Trajectory &gt { bool Test(ref Trajectory t); } public class CountLessThan &lt Atom, Trajectory &gt : ICondition &lt Atom, Trajectory &gt where Trajectory : Trajectories.ICount &lt Atom &gt { public int Value { get; set; } public CountLessThan() { } public bool Test(ref Trajectory t) { return t.Count &lt Value; } } public class CurrentNormLessThan &lt Trajectory &gt : ICondition &lt Complex, Trajectory &gt where Trajectory : Trajectories.ICurrent &lt Complex &gt { public double Value { get; set; } public CurrentNormLessThan() { } public bool Test(ref Trajectory t) { return t.Current.Norm() &lt Value; } } } Now, here's the question: What if I wanted to implement AND predicate? It would be something like this: public class And &lt Atom, CondA, TrajectoryA, CondB, TrajectoryB, Trajectory &gt : ICondition &lt Atom, Trajectory &gt where CondA : ICondition &lt Atom, TrajectoryA &gt where TrajectoryA : // Some interfaces where CondB : ICondition &lt Atom, TrajectoryB &gt where TrajectoryB : // Some interfaces where Trajectory : // MUST IMPLEMENT THE INTERFACES FOR TrajectoryA AND THE INTERFACES FOR TrajectoryB { public CondA A { get; set; } public CondB B { get; set; } public bool Test(ref Trajectory t){ return A.Test(t) && B.Test(t); } } How can I say: support only these trajectories, for which the arguments of AND are ok? So I can be able to write: var vand = new CountLessThan(32) & new CurrentNormLessThan(4.0); I think if I create an orevall interface for every subset of interfaces, I could be able to do it, but it will become quite ugly.

    Read the article

  • Need to convert this for loop to a while loop

    - by Bragaadeesh
    Hi guys, I solved a problem recently. But I have this one piece of code where I dont utilize the for loop initialization and condition check. It looks a bit odd that way for a for loop. I want to convert it into a while loop. Please help me do it. I tried many times, but somewhere something is missing. for(;;current =(current+1)%n){ if(eliminated[current%n]){ continue; }else{ inkiPinki++; if(inkiPinki == m){ eliminated[current%n] = true; printStatus(eliminated, people); remainingGuys--; break; } } } In the above code eliminiated[index] is a boolean.

    Read the article

  • Will these optimizations to my Ruby implementation of diff improve performance in a Rails app?

    - by grg-n-sox
    <tl;dr> In source version control diff patch generation, would it be worth it to use the optimizations listed at the very bottom of this writing (see <optimizations>) in my Ruby implementation of diff for making diff patches? </tl;dr> <introduction> I am programming something I have never done before and there might already be tools out there to do the exact thing I am programming but at this point I am having too much fun to care so I am still going to do it from scratch, even if there is a tool for this. So anyways, I am working on a Ruby on Rails app and need a certain feature. Basically I want each entry in a table of mine, let's say for example a table of video games, to have a stored chunk of text that represents a review or something of the sort for that table entry. However, I want this text to be both editable by any registered user and also keep track of different submissions in a version control system. The simplest solution I could think of is just implement a solution that keeps track of the text body and the diff patch history of different versions of the text body as objects in Ruby and then serialize it, preferably in human readable form (so I'll most likely use YAML for this) for editing if needed due to corruption by a software bug or a mistake is made by an admin doing some version editing. So at first I just tried to dive in head first into this feature to find that the problem of generating a diff patch is more difficult that I thought to do efficiently. So I did some research and came across some ideas. Some I have implemented already and some I have not. However, it all pretty much revolves around the longest common subsequence problem, as you would already know if you have already done anything with diff or diff-like features, and optimization the function that solves it. Currently I have it so it truncates the compared versions of the text body from the beginning and end until non-matching lines are found. Then it solves the problem using a comparison matrix, but instead of incrementing the value stored in a cell when it finds a matching line like in most longest common subsequence algorithms I have seen examples of, I increment when I have a non-matching line so as to calculate edit distance instead of longest common subsequence. Although as far as I can tell between the two approaches, they are essentially two sides of the same coin so either could be used to derive an answer. It then back-traces through the comparison matrix and notes when there was an incrementation and in which adjacent cell (West, Northwest, or North) to determine that line's diff entry and assumes all other lines to be unchanged. Normally I would leave it at that, but since this is going into a Rails environment and not just some stand-alone Ruby script, I started getting worried about needing to optimize at least enough so if a spammer that somehow knew how I implemented the version control system and knew my worst case scenario entry still wouldn't be able to hit the server that bad. After some searching and reading of research papers and articles through the internet, I've come across several that seem decent but all seem to have pros and cons and I am having a hard time deciding how well in this situation that the pros and cons balance out. So are the ones listed here worth it? I have listed them with known pros and cons. </introduction> <optimizations> Chop the compared sequences into multiple chucks of subsequences by splitting where lines are unchanged, and then truncating each section of unchanged lines at the beginning and end of each section. Then solve the edit distance of each subsequence. Pro: Changes the time increase as the changed area gets bigger from a quadratic increase to something more similar to a linear increase. Con: Figuring out where to split already seems like you have to solve edit distance except now you don't care how it is changed. Would be fine if this was solvable by a process closer to solving hamming distance but a single insertion would throw this off. Use a cryptographic hash function to both convert all sequence elements into integers and ensure uniqueness. Then solve the edit distance comparing the hash integers instead of the sequence elements themselves. Pro: The operation of comparing two integers is faster than the operation of comparing two strings, so a slight performance gain is received after every comparison, which can be a lot overall. Con: Using a cryptographic hash function takes time to convert all the sequence elements and may end up costing more time to do the conversion that you gain back from the integer comparisons. You could use the built in hash function for a string but that will not guarantee uniqueness. Use lazy evaluation to only calculate the three center-most diagonals of the comparison matrix and then only calculate additional diagonals as needed. And then also use this approach to possibly remove the need on some comparisons to compare all three adjacent cells as desribed here. Pro: Can turn an algorithm that always takes O(n * m) time and make it so only worst case scenario is that time, best case becomes practically linear, and average case is somewhere between the two. Con: It is an algorithm I've only seen implemented in functional programming languages and I am having a difficult time comprehending how to convert this into Ruby based on how it is described at the site linked to above. Make a C module and do the hard work at the native level in C and just make a Ruby wrapper for it so Ruby can make all the calls to it that it needs. Pro: I have to imagine that evaluating something like this in could be a LOT faster. Con: I have no idea how Rails handles apps with ruby code that has C extensions and it hurts the portability of the app. This is an optimization for after the solving of edit distance, but idea is to store additional combined diffs with the ones produced by each version to make a delta-tree data structure with the most recently made diff as the root node of the tree so getting to any version takes worst case time of O(log n) instead of O(n). Pro: Would make going back to an old version a lot faster. Con: It would mean every new commit, the delta-tree would get a new root node that will cost time to reorganize the delta-tree for an operation that will be carried out a lot more often than going back a version, not to mention the unlikelihood it will be an old version. </optimizations> So are these things worth the effort?

    Read the article

  • Dispose Form opened in MainForm tab

    - by fireBand
    Hi, I have a MainForm which has tab Control and several independent form. I open each Individual From in the tab of the main form. A "Close Tab" button on the MainFrom closes the current tab, its implementation is below. This closes the current tab but what I also need is to dispose the From whose tab is closed but I am not sure how to get the instance of the form.' Any help is appreciated Thanks in Advance. 'Close the current tab Private Sub CloseCurrentTab() 'Close the current tab Dim tabPageSave As TabPage tabPageSave = tcDisplayDetails.SelectedTab tcDisplayDetails.TabPages.Remove(tabPageSave) End Sub

    Read the article

  • Checkbox control in Asp.Net

    - by Sivakumar
    Hello, Actually I'm trying to capture person's current and permanent address. In this case if d current and permanent address same means no need to enter twise. Here I'm using a checkbox. If d checkbox s checked the current address plased in permanent address too. Help me to do tat.

    Read the article

  • Web service for Location name using Latitude & Longtitude

    - by Joy
    I have an iPhone application where i need to find out the current location(in terms of city name or probably the address). But i'm not been able to do that. I can find out the current latitude and longitude. Is there any web service(preferably free of cost) which can return me the current location name if i supply the latitude and longitude? Waiting For any reply. Thanks in advance.. Joy

    Read the article

  • Custom Monitor Resolution not recognized by Java

    - by Angie
    My weird monitor's native resolution isn't recognized by Windows, so I have to set a custom resolution for it. The problem is that java doesn't recognize it since it's not on Win7's "approved" list, so full-screen mode gets "stuck". Netbeans comes out of full-screen fine, so there has to be a way around this. Anyone know it? This example reproduces the issue: package resolutionexample; import java.awt.Dimension; import java.awt.DisplayMode; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import javax.swing.JFrame; import javax.swing.SwingUtilities; public class Main { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable(){ public void run() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); DisplayMode currentDM = gd.getDisplayMode(); boolean currentInAvailable = false; System.out.println("Available resolutions:"); for ( DisplayMode availDM : gd.getDisplayModes() ){ //System.out.println(availDM.getWidth() + "x" + availDM.getHeight()); if ( availDM.equals(currentDM) ){ currentInAvailable = true; } } System.out.println("Current resolution: " + currentDM.getWidth() + "x" + currentDM.getHeight() ); System.out.println("Current in available: " + currentInAvailable); JFrame frame = new JFrame("Resolution Bug Example"); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); if ( !gd.isFullScreenSupported() ){System.exit(0);} gd.setFullScreenWindow(frame); gd.setFullScreenWindow(null); } }); } } Output running 1680x1050 (the monitor's wonky native resolution): run: Available resolutions: Current resolution: 1680x1050 Current in available: false Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Invalid display mode at sun.awt.Win32GraphicsDevice.setDisplayMode(Win32GraphicsDevice.java:393) at sun.awt.Win32GraphicsDevice.setFullScreenWindow(Win32GraphicsDevice.java:329) at resolutionexample.Main$1.run(Main.java:43) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:597) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) BUILD SUCCESSFUL (total time: 2 seconds) Output if I set my resolution to 1024x768 before running: run: Available resolutions: Current resolution: 1024x768 Current in available: true BUILD SUCCESSFUL (total time: 2 seconds)

    Read the article

  • Lost cert for published app

    - by John in MD
    I have a free app published in Android market. I have lost the certificate used to sign the current version but I want to publish an updated version. Android market refuses to accept my upgrade because it is signed by a new certificate. I realize the users will have to uninstall the current version to get the upgrade but it's not clear how to get the updated version into the market so that the current users will find it. What are my options? Thanks, John

    Read the article

  • Do we affect multiple users in ASP.NET when we set the Thread CurrentCulture/CurentUICulture?

    - by Nikolay
    When we set the CurrentCulture and/or CurrentUICulture we do this on the current thread like this: Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB"); Doest this mean we could affect the culture settings of multiple users of our web application as their requests may reuse the threads from pool? I am working on an ASP.NET MVC application where each user may have own culture setting specified in his/her account data. When the user logs in, the culture setting is retrieved from the database and has to be set as current culture. My worry is that setting the current culture on the current thread may affect another user request reusing this thread. I am even more concerned reading this: ASP.NET not only uses a thread pool, but may switch threads during request processing.

    Read the article

  • Problem with Validate Anti Forgery

    - by Mikael Egnér
    Hi! I have a problem regarding MVC Anti forgery token. When I do my authentication I have pseudo code like this: var user = userRepository.GetByEmail(email); System.Threading.Thread.CurrentPrincipal = HttpContext.Current.User = user; by doing so I'm able to get the current user in my code like this: var user = HttpContext.Current.User as EntityUser; This works fine until I add the [ValidateAntiForgeryToken] attribute to an action. When I add the attribute I get A required anti-forgery token was not supplied or was invalid. If I comment out this line: System.Threading.Thread.CurrentPrincipal = HttpContext.Current.User = user; The antiforgery validation works fine, but the I don't have my convenient way of getting my "EntityUser" from the HttpContext. Any ideas of how to work around this? Best regards Mikael

    Read the article

  • CodeContracts: ccrewrite fails with Object reference not set to an instance of an object

    - by Vyas Bharghava
    The below code makes ccrewrite blow up! Ideas? BTW, If you comment out the ActualClass, ccrewrite succeeds... [ContractClass(typeof(TestContracts))] interface ITestInterface { bool IsStarted { get; set; } void Begin(); } class ActualClass : ITestInterface { public bool IsStarted { get; set; } public void Begin() { this.IsStarted = true; } } [ContractClassFor(typeof(ITestInterface))] class TestContracts : ITestInterface { ITestInterface Current { get; set; } private TestContracts() { Current = this; } #region ITestInterface Members bool ITestInterface.IsStarted { get; set; } void ITestInterface.Begin() { Contract.Requires(!Current.IsStarted); Contract.Ensures(Current.IsStarted); } Thanks in advance!

    Read the article

  • rewrite rule to switch to subfolder

    - by Midday
    I'm deploying a Wordpress blog, but I don't want to overwrite the current site yet. public_html/. <-- the current site public_html/wp/. <-- the new site How must my .htaccess look like so I can seamlessly switch from the current site to the new one so that http://domain.tld shows the new site like it would be directly in the public_html folder

    Read the article

  • Optimizing ROW_NUMBER() in SQL Server

    - by BlueRaja
    We have a number of machines which record data into a database at sporadic intervals. For each record, I'd like to obtain the time period between this recording and the previous recording. I can do this using ROW_NUMBER as follows: WITH TempTable AS ( SELECT *, ROW_NUMBER() OVER (PARTITION BY Machine_ID ORDER BY Date_Time) AS Ordering FROM dbo.DataTable ) SELECT [Current].*, Previous.Date_Time AS PreviousDateTime FROM TempTable AS [Current] INNER JOIN TempTable AS Previous ON [Current].Machine_ID = Previous.Machine_ID AND Previous.Ordering = [Current].Ordering + 1 The problem is, it goes really slow (several minutes on a table with about 10k entries) - I tried creating separate indicies on Machine_ID and Date_Time, and a single joined-index, but nothing helps. Is there anyway to rewrite this query to go faster?

    Read the article

  • cache and web-farm

    - by user285336
    I need to deploy my web-application on web-farm. Application has the following strings: public static X509Certificate2 GetIdCertificate() { string cacheKey = "Neogov.Insight.IdentityProvider.PrivateKey"; if (HttpContext.Current.Cache[cacheKey] == null) { //Load new. HttpContext.Current.Cache[cacheKey] = new X509Certificate2( System.Web.HttpContext.Current.Server.MapPath("~/") + "\\ID\\" + Neogov.Insight.IdentityProvider.BLL.IdConfig.Instance.IdPKeyFile, Neogov.Insight.IdentityProvider.BLL.IdConfig.Instance.IdPKeyPassword, X509KeyStorageFlags.MachineKeySet); } return (X509Certificate2)HttpContext.Current.Cache[cacheKey]; } will it work or not? If not then how to solve and what is solution? Thanks

    Read the article

  • Synchronizing thread communication?

    - by Roger Alsing
    Just for the heck of it I'm trying to emulate how JRuby generators work using threads in C#. Also, I'm fully aware that C# haas built in support for yield return, I'm just toying around a bit. I guess it's some sort of poor mans coroutines by keeping multiple callstacks alive using threads. (even though none of the callstacks should execute at the same time) The idea is like this: The consumer thread requests a value The worker thread provides a value and yields back to the consumer thread Repeat untill worker thread is done So, what would be the correct way of doing the following? //example class Program { static void Main(string[] args) { ThreadedEnumerator<string> enumerator = new ThreadedEnumerator<string>(); enumerator.Init(() => { for (int i = 1; i < 100; i++) { enumerator.Yield(i.ToString()); } }); foreach (var item in enumerator) { Console.WriteLine(item); }; Console.ReadLine(); } } //naive threaded enumerator public class ThreadedEnumerator<T> : IEnumerator<T>, IEnumerable<T> { private Thread enumeratorThread; private T current; private bool hasMore = true; private bool isStarted = false; AutoResetEvent enumeratorEvent = new AutoResetEvent(false); AutoResetEvent consumerEvent = new AutoResetEvent(false); public void Yield(T item) { //wait for consumer to request a value consumerEvent.WaitOne(); //assign the value current = item; //signal that we have yielded the requested enumeratorEvent.Set(); } public void Init(Action userAction) { Action WrappedAction = () => { userAction(); consumerEvent.WaitOne(); enumeratorEvent.Set(); hasMore = false; }; ThreadStart ts = new ThreadStart(WrappedAction); enumeratorThread = new Thread(ts); enumeratorThread.IsBackground = true; isStarted = false; } public T Current { get { return current; } } public void Dispose() { enumeratorThread.Abort(); } object System.Collections.IEnumerator.Current { get { return Current; } } public bool MoveNext() { if (!isStarted) { isStarted = true; enumeratorThread.Start(); } //signal that we are ready to receive a value consumerEvent.Set(); //wait for the enumerator to yield enumeratorEvent.WaitOne(); return hasMore; } public void Reset() { throw new NotImplementedException(); } public IEnumerator<T> GetEnumerator() { return this; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return this; } } Ideas?

    Read the article

  • Saving jQuery UI Sortable's order to Backbone.js Collection

    - by VirtuosiMedia
    I have a Backbone.js collection that I would like to be able to sort using jQuery UI's Sortable. Nothing fancy, I just have a list that I would like to be able to sort. The problem is that I'm not sure how to get the current order of items after being sorted and communicate that to the collection. Sortable can serialize itself, but that won't give me the model data I need to give to the collection. Ideally, I'd like to be able to just get an array of the current order of the models in the collection and use the reset method for the collection, but I'm not sure how to get the current order. Please share any ideas or examples for getting an array with the current model order.

    Read the article

  • iPhone Map: Identifying Users Location

    - by senfo
    I have a number of annotations on my map, in addition to the users current location. This works fine, except the default color for the users current location is the same as all of the other annotations. I'd like to make the pin green for the users current location so that it's uniquely identifiable from the other pins. How do I do this? Bellow is the method I've been using (I can't find a way to determine which annotation is the users current location): - (MKAnnotationView *)mapView:(MKMapView *)mapViewLocal viewForAnnotation:(id <MKAnnotation>)annotation { static NSString *identifier = @"Pin"; MKPinAnnotationView *pinView = (MKPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:identifier]; if (pinView == nil) { pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier] autorelease]; pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; pinView.animatesDrop = YES; pinView.canShowCallout = YES; } else { pinView.annotation = annotation; } return pinView; }

    Read the article

  • two threads acting on the same runnable

    - by Eslam
    Given: public class Thread1 { int x = 0; public class Runner implements Runnable { public void run() { int current = 0; for (int i = 0; i < 4; i++) { current = x; System.out.print(current + " "); x = current + 2; } } } public void go() { Runnable r1 = new Runner(); new Thread(r1).start(); new Thread(r1).start(); } public static void main(String[] args) { new Thread1().go(); } } Which two are possible results? (Choose two) A. 0, 2, 4, 4, 6, 8, 10, 6, B. 0, 2, 4, 6, 8, 10, 2, 4, C. 0, 2, 4, 6, 8, 10, 12, 14, D. 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, E. 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14, i chosed A,B but i'm not certain is those is the true or not.

    Read the article

  • Articles about replication schemes/algorithms?

    - by jkff
    I'm designing an hierarchical distributed system (every node has zero or more "master" nodes to which it propagates its current data). The data gets continuously updated and I'd like to guarantee that at least N nodes have almost-current data at any given time. I do not need complete consistency, only eventual consistency (t.i. for any time instant, the current snapshot of data should eventually appear on at least N nodes. It is tricky to define the term "current" here, but still). Nodes may fail and go back up at any moment, and there is no single "central" node. O overflowers! Point me to some good papers describing replication schemes. I've so far found one: Consistency Management in Optimistic Replication Algorithms

    Read the article

< Previous Page | 77 78 79 80 81 82 83 84 85 86 87 88  | Next Page >