Search Results

Search found 10381 results on 416 pages for 'delegate and events'.

Page 114/416 | < Previous Page | 110 111 112 113 114 115 116 117 118 119 120 121  | Next Page >

  • DataContractSerializer case-insensitive datamember bug

    - by Andrew Bullock
    Here is my class: [DataContract] public class EventIndex : IExtensibleDataObject { public ExtensionDataObject ExtensionData { get; set; } [DataMember] private readonly IList<EventDescription> events; public IEnumerable<EventDescription> Events { get { return events; } } public EventIndex() { events = new List<EventDescription>(); } } As you can see, events is marked as a member. When I try and deserialize one of these classes, ReadObject throws a NullReferenceException. After a morning spent inside reflector, it turns out that its trying to deserialize the events collection into the Events getter. If I rename one of the members (events\ Events) I don't have an issue. Is there a way to make this work properly, without renaming workarounds or other such nonsense?

    Read the article

  • How can I detect touch events on a UIImageView inside a deep hierarchy of UIViews?

    - by jester
    I am developing a simple game on iPhone and I started with a View based application, and through the UIViewController I am loading a custom UIView that contains some more UIViews and some UIImageViews. I want to detect touch events on some of the UIImageViews, but I wasn't able so far. I've created a second project for testing purposes and figured that UIImageViews handle touch events when the hierarchy is like : UIViewController - UIView - UIImageView, but when it's like : UIViewController - UIView - UIView - UIImageView they are not detected. Notes: - userInteractionEnabled is YES in all cases - all UIViews and UIImageViews I mention above are custom subclasses. Can you think of any reason why, when a custom UIImageView gets deeper in the view hierarchy can't receive touch events?

    Read the article

  • Google Analytics - Events versus Pageviews, can you compare them?

    - by Aart Nicolai
    Hi, A mortgage page on our website is accesible by multiple links on one page. In order to determine which of the links on that same page has been clicked on, I use event tracking. All events for these links are being stored under the category: "mortgage" When I look at the total number of pageviews for this mortgage page and the total number of events for the event category "mortgage", the number of pageviews is 10%-20% higher. My questions are: Can I compare pageviews and events? If not, why not? Thanks, Aart Nicolai (funda.nl)

    Read the article

  • Can I prevent Flash's Input Events from stacking up when my framerate low?

    - by Matt W
    My Flash game targets 24 fps, but slows to 10 on slower machines. This is fine, except Flash decides to throttle the queue of incoming MouseEvent and KeyboardEvents, and they stack up and the Events fall behind. Way behind. It's so bad that, at 10 fps, if I spam the Mouse and Keyboard for a few seconds not much happens, then, after I stop, the game seems to play itself for the next 5 seconds as the Events trickle in. Spooky, I know. Does anyone know a way around this? I basically need to say to Flash, "I know you think we're falling behind, but throttling the input events won't help. Give them to me as soon as you get them, please."

    Read the article

  • MSSQL - Select one random record not showing duplicates

    - by Lukes123
    I have two tables, events and photos, which relate together via the 'Event_ID' column. I wish to select ONE random photo from each event and display them. How can I do this? I have the following which displays all the photos which are associated. How can I limit it to one per event? SELECT Photos.Photo_Id, Photos.Photo_Path, Photos.Event_Id, Events.Event_Title, Events.Event_StartDate, Events.Event_EndDate FROM Photos, Events WHERE Photos.Event_Id = Events.Event_Id AND Events.Event_EndDate < GETDATE() AND Events.Event_EndDate IS NOT NULL AND Events.Event_StartDate IS NOT NULL ORDER BY NEWID() Thanks Luke Stratton

    Read the article

  • How do I detect whether a browser supports mouseover events?

    - by Damovisa
    Let's assume I have a web page which has some onmouseover javascript behaviour to drop down a menu (or something similar) Obviously, this isn't going to work on a touch device like the iPad or smartphones. How can I detect whether the browser supports hover events like onmouseover or onmouseout and the :hover pseudotag in CSS? Note: I know that if I'm concerned about this I should write it a different way, but I'm curious as to whether detection can be done. Edit: When I say, "supports hover events", I really mean, "does the browser have a meaningful representation of hover events". If the hardware supports it but the software doesn't (or vice versa), there's no meaningful representation. With the exception of some upcoming tech, I don't think any touch devices have a meaningful representation of a hover event.

    Read the article

  • SQL Server - Select one random record not showing duplicates

    - by Lukes123
    I have two tables, events and photos, which relate together via the 'Event_ID' column. I wish to select ONE random photo from each event and display them. How can I do this? I have the following which displays all the photos which are associated. How can I limit it to one per event? SELECT Photos.Photo_Id, Photos.Photo_Path, Photos.Event_Id, Events.Event_Title, Events.Event_StartDate, Events.Event_EndDate FROM Photos, Events WHERE Photos.Event_Id = Events.Event_Id AND Events.Event_EndDate < GETDATE() AND Events.Event_EndDate IS NOT NULL AND Events.Event_StartDate IS NOT NULL ORDER BY NEWID() Thanks Luke Stratton

    Read the article

  • How can I receive the "scroll box" type scroll events from a DataGridView?

    - by Simon
    I have a DataGridView, and I'm listening to its Scroll event. This gives me a ScrollEventArgs object whose Type member is supposed to tell me the type of scroll event that has occurred. On the MSDN documentation page it says I should be able to detect movement of the scroll box by listening for events with types ThumbPosition, ThumbTrack, First, Last and EndScroll. However, when I drag the scroll box, I only get events of type LargeDecrement and LargeIncrement. How do I get access to the ThumbPosition, ThumbTrack, First, Last and EndScroll events?

    Read the article

  • Showing login view controller before main tab bar controller

    - by Padawan
    I'm creating an iPad app with a tab bar controller that requires login. So on launch, I want to show a LoginViewController and if login is successful, then show the tab bar controller. This is how I implemented an initial test version (left out some typical header stuff, etc)... AppDelegate.h: @interface AppDelegate_Pad : NSObject <UIApplicationDelegate, LoginViewControllerDelegate> { UIWindow *window; UITabBarController *tabBarController; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet UITabBarController *tabBarController; @end AppDelegate.m: @implementation AppDelegate_Pad @synthesize window; @synthesize tabBarController; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { LoginViewController_Pad *lvc = [[LoginViewController_Pad alloc] initWithNibName:@"LoginViewController_Pad" bundle:nil]; lvc.delegate = self; [window addSubview:lvc.view]; //[lvc release]; [window makeKeyAndVisible]; return YES; } - (void)loginViewControllerDidFinish:(LoginViewController_Pad *)loginViewController { [window addSubview:tabBarController.view]; } - (void)dealloc {...} @end LoginViewController_Pad.h: @protocol LoginViewControllerDelegate; @interface LoginViewController_Pad : UIViewController { id<LoginViewControllerDelegate> delegate; } @property (nonatomic, assign) id <LoginViewControllerDelegate> delegate; - (IBAction)buttonPressed; @end @protocol LoginViewControllerDelegate -(void)loginViewControllerDidFinish:(LoginViewController_Pad *)loginViewController; @end LoginViewController_Pad.m: @implementation LoginViewController_Pad @synthesize delegate; ... - (IBAction)buttonPressed { [self.view removeFromSuperview]; [self.delegate loginViewControllerDidFinish:self]; } ... @end So the app delegate adds the login view controller's view on launch and waits for login to call "did finish" using a delegate. The login view controller calls removeFromSuperView before it calls didFinish. The app delegate then calls addSubView on the tab bar controller's view. If you made it up to this point, thanks, and I have three questions: MAIN QUESTION: Is this the right way to show a view controller before the app's main tab bar controller is displayed? Even though it seems to work, is it a proper way to do it? If I comment out the "lvc release" in the app delegate then the app crashes with EXC_BAD_ACCESS when the button on the login view controller is pressed. Why? With the "lvc release" commented out everything seems to work but on the debugger console it writes this message when the app delegate calls addSubView for the tab bar controller: Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations. What does that mean and do I need to worry about it?

    Read the article

  • Can I "inherit" a delegate? Looking for ways to combine Moq and MSpec without conflicts around It...

    - by Tomas Lycken
    I have started to use MSpec for BDD, and since long ago I use Moq as my mocking framework. However, they both define It, which means I can't have using Moq and using Machine.Specifications in the same code file without having to specify the namespace explicitly each time I use It. Anyone who's used MSpec knows this isn't really an option. I googled for solutions to this problem, and this blogger mentions having forked MSpec for himself, and implemented paralell support for Given, When, Then. I'd like to do this, but I can't figure out how to declare for example Given without having to go through the entire framework looking for references to Establish, and changing code there to match that I want either to be OK. For reference, the Establish, Because and It are declared in the following way: public delegate void Establish(); public delegate void Because(); public delegate void It(); What I need is to somehow declare Given, so that everywhere the code looks for an Establish, Given is also OK.

    Read the article

  • How to customize RESTful Routes in Rails (basics)

    - by viatropos
    I have read through the Rails docs for Routing, Restful Resources, and the UrlHelper, and still don't understand best practices for creating complex/nested routes. The example I'm working on now is for events, which has_many rsvps. So a user's looking through a list of events, and clicks register, and goes through a registration process, etc. I want the urls to look like this: /events /events/123 # possible without title, like SO /events/123/my-event-title # canonical version /events/my-category/123/my-event-title # also possible like this /events/123/my-event-title/registration/new ... and all the restful nested resouces. Question is, how do I accomplish this with the minimal amount of code? Here's what I currently have: map.resources :events do |event| event.resources :rsvps, :as => "registration" end That gets me this: /events/123/registration What's the best way to accomplish the other 2 routes? /events/123/my-event-title # canonical version /events/my-category/123/my-event-title # also possible like this Where my-category is just an array of 10 possible types the event can be. I've modified Event#to_param to return "#{self.id.to_s}-#{self.title.parameterize}", but I'd prefer to have /id/title with the whole canonical-ness

    Read the article

  • How can I show print statements in debug mode of OPNET Modeler?

    - by Here now
    I'm writing C++ code in OPNET Modeler. I try to simulate my scenario in debugger mode & I need to trace the function that I wrote it. I need to show print statements which I put it in my code. I used in debugger mode: ***ltr function_name()*** then ***c*** But the result looks like: Type 'help' for Command Summary ODB> ltr enqueue_packet() Added trace #0: trace on label (enqueue_packet()) ODB> c |-----------------------------------------------------------------------------| | Progress: Time (1 min. 52 sec.); Events (500,002) | | Speed: Average (82,575 events/sec.); Current (82,575 events/sec.) | | Time : Elapsed (6.1 sec.) | | DES Log: 28 entries | |-----------------------------------------------------------------------------| |-----------------------------------------------------------------------------| | Progress: Time (1 min. 55 sec.); Events (1,000,002) | | Speed: Average (69,027 events/sec.); Current (59,298 events/sec.) | | Time : Elapsed (14 sec.) | | DES Log: 28 entries | |-----------------------------------------------------------------------------| |-----------------------------------------------------------------------------| | Progress: Time (1 min. 59 sec.); Events (1,500,002) | | Speed: Average (51,464 events/sec.); Current (34,108 events/sec.) | | Time : Elapsed (29 sec.) | | DES Log: 28 entries | |-----------------------------------------------------------------------------| |-----------------------------------------------------------------------------| | Simulation Completed - Collating Results. | | Events: Total (1,591,301); Average Speed (48,803 events/sec.) | | Time : Elapsed (33 sec.); Simulated (2 min. 0 sec.) | | DES Log: 29 entries | |-----------------------------------------------------------------------------| |-----------------------------------------------------------------------------| | Reading network model. | |-----------------------------------------------------------------------------| I need to show the print statements in my code. Where it has to be appeared? Is there any step before run the simulation to insure that OPNET debugger using Visual Studio & go through my code??

    Read the article

  • Subjective question...would you use the Action delegate to avoid duplication of code?

    - by Seth Spearman
    Hello, I just asked a question that helps about using generics (or polymorphism) to avoid duplication of code. I am really trying to follow the DRY principle. So I just ran into the following code... Sub OutputDataToExcel() OutputLine("Output DataBlocks", 1) OutputDataBlocks() OutputLine("") OutputLine("Output Numbered Inventory", 1) OutputNumberedInventory() OutputLine("") OutputLine("Output Item Summaries", 1) OutputItemSummaries() OutputLine("") End Sub Should I rewrite this code to be as follows using the Action delegate... Sub OutputDataToExcel() OutputData("Output DataBlocks", New Action(AddressOf OutputDataBlocks)) OutputData("Output Numbered Inventory", New Action(AddressOf OutputNumberedInventory)) OutputData("Output Item Summaries", New Action(AddressOf OutputItemSummaries)) End Sub Sub OutputData(ByVal outputDescription As String, ByVal outputType As Action) OutputLine(outputDescription, 1) outputType() OutputLine("") End Sub I realize this question is subjective. I am just wondering about how religiously you follow DRY. Would you do this? Seth

    Read the article

  • How can I access data that's stored in my App Delegate from my various view controllers?

    - by BeachRunnerJoe
    This question is similar to this other post, but I'm new to iPhone development and I'm getting used to the good practices for organizing my data throughout my app. I understand the ApplicationDelegate object to be the best place to manage data that is global to my app, correct? If so, how can I access data that's stored in my App Delegate from various view controllers? Specifically, I have an array of table section titles for my root table view controller created as such... appdelegate.m sectionTitles = [[NSArray alloc] initWithObjects: @"Title1", @"Title2", @"Title3", nil]; rootViewController.appDelegate = self; and I need to access it throughout the different views of my app, like such... rootviewcontroller.m NSUInteger numSections = [self.appDelegate.sectionTitles count]; Is this the best way to do it or are there any reasons I should organize my data a better way? Thanks so much in advance for your help!

    Read the article

  • Why does Windows Event Log stop logging events before maximum log size is reached?

    - by Tuure Laurinolli
    I have a service that produces a lot of event log output. Currently the event log is configured to overwrite any old events to keep the log from ever getting full. We have also increased the event log size considerably (to about 600 MB). Recently the service started reporting errors to its clients, and the error message it was sending to its clients is "The event log file is full". How can this be, when event log is configured to overwrite as necessary? In our hurry to get the service back up we cleared the event log without saving its contents, but most likely it had not reached 600 MB yet, judging from sizes of some earlier log dumps. There is also MS KB entry 312571, which reports that a hot fix to a similar issue is available, but the the configuration that the fix applies to is not exactly the same we have. Specifically, the fix only applies if event logs are configured to never overwrite old events. I wonder if this has something to do with the fact that the log files apparently are memory-mapped. What happens if the system runs out of address space to map files to?

    Read the article

  • Why do we need the "event" keyword while defining events ?

    - by Puneet Dudeja
    I don't understand why do we need the "event" keyword while defining events, when we can do the same thing without using "event" keyword, just by using the delegates. e.g. public delegate void CustomEventHandler(int a, string b); public event CustomEventHandler customEvent; customEvent += new CustomEventHandler(customEventHandler); customEvent(1,"a"); // Raising the event Here if I remove the "event" keyword from the second line, then also I can raise the event by invoking the delegate. Can anybody please tell me why is this event keyword needed ?

    Read the article

  • Is there anything called solicit and unsolicit messages/events in window programming?

    - by AKN
    Can someone pls tell me do we have solic & unsolic message/events in MFC or window programming? In devices solic response and unsolic response is said as immediate response (like acknowledgement to commands) and late response (generated without any further commands being sent) respectively. Likewise can we say events as solic / unsolic based on immediate occurrence and late occurrence?

    Read the article

  • Does Visual Studio 2010 support something like Eclipse's "Generate delegate methods"?

    - by devoured elysium
    Eclipse allows us to define a class as: interface MyInterface { void methodA(); int methodB(); } class A : MyInterface { MyInterface myInterface; } and then with this "Generate delegate methods", it will implement all needed methods for the interface, redirecting their logic to myInterface's methods: class A : MyInterface { MyInterface myInterface; public void methodA() { myInterface.methodA(); } public int methodB() { return myInterface.methodB(); } } Is it possible to accomplish the same with VS2010? And with R#? Thanks

    Read the article

  • Is there a way in C# 4.0 to have a method take a delegate with the parameters baked in?

    - by Rob Packwood
    I have this code for reporting on a simple demo app I am writing: private static void ReportOnTimedProcess(Action process) { var stopwatch = new Stopwatch(); stopwatch.Start(); process(); stopwatch.Stop(); Console.WriteLine("Process took {0} seconds", stopwatch.ElapsedMilliseconds*1000); } I basically want to track the time of any process. I am trying to have this method take a delegate as a parameter that can have any number of varying parameters. Is there some way an Expression can do this?

    Read the article

  • Parallelism in .NET – Part 13, Introducing the Task class

    - by Reed
    Once we’ve used a task-based decomposition to decompose a problem, we need a clean abstraction usable to implement the resulting decomposition.  Given that task decomposition is founded upon defining discrete tasks, .NET 4 has introduced a new API for dealing with task related issues, the aptly named Task class. The Task class is a wrapper for a delegate representing a single, discrete task within your decomposition.  We will go into various methods of construction for tasks later, but, when reduced to its fundamentals, an instance of a Task is nothing more than a wrapper around a delegate with some utility functionality added.  In order to fully understand the Task class within the new Task Parallel Library, it is important to realize that a task really is just a delegate – nothing more.  In particular, note that I never mentioned threading or parallelism in my description of a Task.  Although the Task class exists in the new System.Threading.Tasks namespace: Tasks are not directly related to threads or multithreading. Of course, Task instances will typically be used in our implementation of concurrency within an application, but the Task class itself does not provide the concurrency used.  The Task API supports using Tasks in an entirely single threaded, synchronous manner. Tasks are very much like standard delegates.  You can execute a task synchronously via Task.RunSynchronously(), or you can use Task.Start() to schedule a task to run, typically asynchronously.  This is very similar to using delegate.Invoke to execute a delegate synchronously, or using delegate.BeginInvoke to execute it asynchronously. The Task class adds some nice functionality on top of a standard delegate which improves usability in both synchronous and multithreaded environments. The first addition provided by Task is a means of handling cancellation via the new unified cancellation mechanism of .NET 4.  If the wrapped delegate within a Task raises an OperationCanceledException during it’s operation, which is typically generated via calling ThrowIfCancellationRequested on a CancellationToken, or if the CancellationToken used to construct a Task instance is flagged as canceled, the Task’s IsCanceled property will be set to true automatically.  This provides a clean way to determine whether a Task has been canceled, often without requiring specific exception handling. Tasks also provide a clean API which can be used for waiting on a task.  Although the Task class explicitly implements IAsyncResult, Tasks provide a nicer usage model than the traditional .NET Asynchronous Programming Model.  Instead of needing to track an IAsyncResult handle, you can just directly call Task.Wait() to block until a Task has completed.  Overloads exist for providing a timeout, a CancellationToken, or both to prevent waiting indefinitely.  In addition, the Task class provides static methods for waiting on multiple tasks – Task.WaitAll and Task.WaitAny, again with overloads providing time out options.  This provides a very simple, clean API for waiting on single or multiple tasks. Finally, Tasks provide a much nicer model for Exception handling.  If the delegate wrapped within a Task raises an exception, the exception will automatically get wrapped into an AggregateException and exposed via the Task.Exception property.  This exception is stored with the Task directly, and does not tear down the application.  Later, when Task.Wait() (or Task.WaitAll or Task.WaitAny) is called on this task, an AggregateException will be raised at that point if any of the tasks raised an exception.  For example, suppose we have the following code: Task taskOne = new Task( () => { throw new ApplicationException("Random Exception!"); }); Task taskTwo = new Task( () => { throw new ArgumentException("Different exception here"); }); // Start the tasks taskOne.Start(); taskTwo.Start(); try { Task.WaitAll(new[] { taskOne, taskTwo }); } catch (AggregateException e) { Console.WriteLine(e.InnerExceptions.Count); foreach (var inner in e.InnerExceptions) Console.WriteLine(inner.Message); } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } Here, our routine will print: 2 Different exception here Random Exception! Note that we had two separate tasks, each of which raised two distinctly different types of exceptions.  We can handle this cleanly, with very little code, in a much nicer manner than the Asynchronous Programming API.  We no longer need to handle TargetInvocationException or worry about implementing the Event-based Asynchronous Pattern properly by setting the AsyncCompletedEventArgs.Error property.  Instead, we just raise our exception as normal, and handle AggregateException in a single location in our calling code.

    Read the article

  • Taming Hopping Windows

    - by Roman Schindlauer
    At first glance, hopping windows seem fairly innocuous and obvious. They organize events into windows with a simple periodic definition: the windows have some duration d (e.g. a window covers 5 second time intervals), an interval or period p (e.g. a new window starts every 2 seconds) and an alignment a (e.g. one of those windows starts at 12:00 PM on March 15, 2012 UTC). var wins = xs     .HoppingWindow(TimeSpan.FromSeconds(5),                    TimeSpan.FromSeconds(2),                    new DateTime(2012, 3, 15, 12, 0, 0, DateTimeKind.Utc)); Logically, there is a window with start time a + np and end time a + np + d for every integer n. That’s a lot of windows. So why doesn’t the following query (always) blow up? var query = wins.Select(win => win.Count()); A few users have asked why StreamInsight doesn’t produce output for empty windows. Primarily it’s because there is an infinite number of empty windows! (Actually, StreamInsight uses DateTimeOffset.MaxValue to approximate “the end of time” and DateTimeOffset.MinValue to approximate “the beginning of time”, so the number of windows is lower in practice.) That was the good news. Now the bad news. Events also have duration. Consider the following simple input: var xs = this.Application                 .DefineEnumerable(() => new[]                     { EdgeEvent.CreateStart(DateTimeOffset.UtcNow, 0) })                 .ToStreamable(AdvanceTimeSettings.IncreasingStartTime); Because the event has no explicit end edge, it lasts until the end of time. So there are lots of non-empty windows if we apply a hopping window to that single event! For this reason, we need to be careful with hopping window queries in StreamInsight. Or we can switch to a custom implementation of hopping windows that doesn’t suffer from this shortcoming. The alternate window implementation produces output only when the input changes. We start by breaking up the timeline into non-overlapping intervals assigned to each window. In figure 1, six hopping windows (“Windows”) are assigned to six intervals (“Assignments”) in the timeline. Next we take input events (“Events”) and alter their lifetimes (“Altered Events”) so that they cover the intervals of the windows they intersect. In figure 1, you can see that the first event e1 intersects windows w1 and w2 so it is adjusted to cover assignments a1 and a2. Finally, we can use snapshot windows (“Snapshots”) to produce output for the hopping windows. Notice however that instead of having six windows generating output, we have only four. The first and second snapshots correspond to the first and second hopping windows. The remaining snapshots however cover two hopping windows each! While in this example we saved only two events, the savings can be more significant when the ratio of event duration to window duration is higher. Figure 1: Timeline The implementation of this strategy is straightforward. We need to set the start times of events to the start time of the interval assigned to the earliest window including the start time. Similarly, we need to modify the end times of events to the end time of the interval assigned to the latest window including the end time. The following snap-to-boundary function that rounds a timestamp value t down to the nearest value t' <= t such that t' is a + np for some integer n will be useful. For convenience, we will represent both DateTime and TimeSpan values using long ticks: static long SnapToBoundary(long t, long a, long p) {     return t - ((t - a) % p) - (t > a ? 0L : p); } How do we find the earliest window including the start time for an event? It’s the window following the last window that does not include the start time assuming that there are no gaps in the windows (i.e. duration < interval), and limitation of this solution. To find the end time of that antecedent window, we need to know the alignment of window ends: long e = a + (d % p); Using the window end alignment, we are finally ready to describe the start time selector: static long AdjustStartTime(long t, long e, long p) {     return SnapToBoundary(t, e, p) + p; } To find the latest window including the end time for an event, we look for the last window start time (non-inclusive): public static long AdjustEndTime(long t, long a, long d, long p) {     return SnapToBoundary(t - 1, a, p) + p + d; } Bringing it together, we can define the translation from events to ‘altered events’ as in Figure 1: public static IQStreamable<T> SnapToWindowIntervals<T>(IQStreamable<T> source, TimeSpan duration, TimeSpan interval, DateTime alignment) {     if (source == null) throw new ArgumentNullException("source");     // reason about DateTime and TimeSpan in ticks     long d = Math.Min(DateTime.MaxValue.Ticks, duration.Ticks);     long p = Math.Min(DateTime.MaxValue.Ticks, Math.Abs(interval.Ticks));     // set alignment to earliest possible window     var a = alignment.ToUniversalTime().Ticks % p;     // verify constraints of this solution     if (d <= 0L) { throw new ArgumentOutOfRangeException("duration"); }     if (p == 0L || p > d) { throw new ArgumentOutOfRangeException("interval"); }     // find the alignment of window ends     long e = a + (d % p);     return source.AlterEventLifetime(         evt => ToDateTime(AdjustStartTime(evt.StartTime.ToUniversalTime().Ticks, e, p)),         evt => ToDateTime(AdjustEndTime(evt.EndTime.ToUniversalTime().Ticks, a, d, p)) -             ToDateTime(AdjustStartTime(evt.StartTime.ToUniversalTime().Ticks, e, p))); } public static DateTime ToDateTime(long ticks) {     // just snap to min or max value rather than under/overflowing     return ticks < DateTime.MinValue.Ticks         ? new DateTime(DateTime.MinValue.Ticks, DateTimeKind.Utc)         : ticks > DateTime.MaxValue.Ticks         ? new DateTime(DateTime.MaxValue.Ticks, DateTimeKind.Utc)         : new DateTime(ticks, DateTimeKind.Utc); } Finally, we can describe our custom hopping window operator: public static IQWindowedStreamable<T> HoppingWindow2<T>(     IQStreamable<T> source,     TimeSpan duration,     TimeSpan interval,     DateTime alignment) {     if (source == null) { throw new ArgumentNullException("source"); }     return SnapToWindowIntervals(source, duration, interval, alignment).SnapshotWindow(); } By switching from HoppingWindow to HoppingWindow2 in the following example, the query returns quickly rather than gobbling resources and ultimately failing! public void Main() {     var start = new DateTimeOffset(new DateTime(2012, 6, 28), TimeSpan.Zero);     var duration = TimeSpan.FromSeconds(5);     var interval = TimeSpan.FromSeconds(2);     var alignment = new DateTime(2012, 3, 15, 12, 0, 0, DateTimeKind.Utc);     var events = this.Application.DefineEnumerable(() => new[]     {         EdgeEvent.CreateStart(start.AddSeconds(0), "e0"),         EdgeEvent.CreateStart(start.AddSeconds(1), "e1"),         EdgeEvent.CreateEnd(start.AddSeconds(1), start.AddSeconds(2), "e1"),         EdgeEvent.CreateStart(start.AddSeconds(3), "e2"),         EdgeEvent.CreateStart(start.AddSeconds(9), "e3"),         EdgeEvent.CreateEnd(start.AddSeconds(3), start.AddSeconds(10), "e2"),         EdgeEvent.CreateEnd(start.AddSeconds(9), start.AddSeconds(10), "e3"),     }).ToStreamable(AdvanceTimeSettings.IncreasingStartTime);     var adjustedEvents = SnapToWindowIntervals(events, duration, interval, alignment);     var query = from win in HoppingWindow2(events, duration, interval, alignment)                 select win.Count();     DisplayResults(adjustedEvents, "Adjusted Events");     DisplayResults(query, "Query"); } As you can see, instead of producing a massive number of windows for the open start edge e0, a single window is emitted from 12:00:15 AM until the end of time: Adjusted Events StartTime EndTime Payload 6/28/2012 12:00:01 AM 12/31/9999 11:59:59 PM e0 6/28/2012 12:00:03 AM 6/28/2012 12:00:07 AM e1 6/28/2012 12:00:05 AM 6/28/2012 12:00:15 AM e2 6/28/2012 12:00:11 AM 6/28/2012 12:00:15 AM e3 Query StartTime EndTime Payload 6/28/2012 12:00:01 AM 6/28/2012 12:00:03 AM 1 6/28/2012 12:00:03 AM 6/28/2012 12:00:05 AM 2 6/28/2012 12:00:05 AM 6/28/2012 12:00:07 AM 3 6/28/2012 12:00:07 AM 6/28/2012 12:00:11 AM 2 6/28/2012 12:00:11 AM 6/28/2012 12:00:15 AM 3 6/28/2012 12:00:15 AM 12/31/9999 11:59:59 PM 1 Regards, The StreamInsight Team

    Read the article

  • Two free SQL Server events I'll be presenting at in UK. Come and say hi!

    - by Mladen Prajdic
    SQLBits: April 7th - April 9th 2011 in Brighton, UK Free community event on Saturday (April 9th) with a paid conference day on Friday (April 8th) and a Pre Conference day full of day long seminars (April 7th). It'll be a huge event with over 800 attendees and over 20 MVPs. I'll be presenting on Saturday April 9th.     SQL in the City: July 15th 2011 in London, UK One day of free SQL Server training sponsored by Redgate. Other MVP's that'll be presenting there are Steve Jones (website|twitter), Brad McGehee (blog|twitter) and Grant Fritchey (blog|twitter)   At both conferences I'll be presenting about database testing. In the sessions I'll cover a few things from my book The Red Gate Guide to SQL Server Team based Development like what do we need for testing, how to go about it, what are some of the obstacles we have to overcome, etc… If you're around there come and say Hi!

    Read the article

< Previous Page | 110 111 112 113 114 115 116 117 118 119 120 121  | Next Page >