Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Ochowie posted:

Could you drop this out into a thread-safe helper class? That's how I've been working with hubs and I'm able to trigger async void events for timer ticks and such.

Could you give me a 10-line repro of what you're talking about? I tried something similar last night with no luck, but I may have been missing something because I was doing it after driving for 3 hours.

I'm probably going to end up passing callbacks in like Bognar suggested. It'll bloat things slightly, but not terribly. And I don't think I need multicasting, so it should be more or less functionally equivalent.

New Yorp New Yorp fucked around with this message at 00:20 on Aug 15, 2014

Adbot
ADBOT LOVES YOU

ShaunO
Jan 29, 2006

Ithaqua posted:

Does anyone have any ideas about getting around SignalR's inability to have async event handlers? I'm working on something where I have my application's logic totally platform-agnostic and want to fire events when the internal state changes and needs to be pushed to clients, but SignalR can't handle async void methods.

I don't really understand why SignalR can't handle async methods but in my situation I'm having to call awaitable methods using task.ConfigureAwait(false). I probably need to spawn a new thread worker before I invoke the awaitable method too but in general I found no Tasks to work without the ConfigureAwait(false). There doesn't seem to be much info in my Googling regarding this and the MSDN doc for it sucks cock.

Ochowie
Nov 9, 2007

Ithaqua posted:

Could you give me a 10-line repro of what you're talking about? I tried something similar last night with no luck, but I may have been missing something because I was doing it after driving for 3 hours.

I'm probably going to end up passing callbacks in like Bognar suggested. It'll bloat things slightly, but not terribly. And I don't think I need multicasting, so it should be more or less functionally equivalent.

I basically used the StockTickerHub example and changed it to meet my needs:

code:
public class StockTickerHelper
{
        private readonly static Lazy<StockTickerHelper> _instance = new Lazy<StockTickerHelper>(
            () => new StockTickerHelper(GlobalHost.ConnectionManager.GetHubContext<StockTickerHub>().Clients), true);

        private Timer _timer;

        private StockTickerHelper(IHubConnectionContext<dynamic> clients)
        {
            Clients = clients;
        }

        public async Task<Quote> Start()
        {
            _timer = new Timer(UpdatePrices, null, 20000, Timeout.Infinite); 
        }

        private async void UpdatePrices(object state)
        {
           var results = await Task.WhenAll(quoteTasks);
        }
}
Then in the hub

code:
public class StockTickerHub : Hub
{
        private readonly StockTickerHelper _stockTickerHelper;
        private string _symbol;

        public StockTickerHub() : this(StockTickerHelper.Instance) { }

        public StockTickerHub(StockTickerHelper stockTicker)
        {
            _stockTickerHelper = stockTicker;
        }
}
Not listed here but the helper class is the one that sends the messages to the client using the context it pulls in the constructor.

JawnV6
Jul 4, 2004

So hot ...
I have more serial port weirdness I need to figure out.

Right now in C# I'm using a Timer to poll a serial device. It writes to the port, then does a try{} to catch a timeout on the Read in case the device does not respond.

A different test requires that the PC avoid writing anything to the port for an unknown time. I've found an example on setting up a DataReceived Handler. It seems straightforward to have a button that sets up the handler, turns off the timer, and wait for the device to deliver data.

However, I need the ability to go back to polling. I think I can get away with having the DataReceived handler always attached. It'll check if the timer's active and return without touching the port. Essentially treating the timer's Enable as the differentiator between the two states. Is that going to work? I understand there's some weirdness in the handler as I can't change UI elements directly, I have to throw it through an Invoke delegate. Can I sample the timer's Enable on the other thread without issues? It would be pulled low by a button and re-enabled at the end of the handler if the proper data is received.

crashdome
Jun 28, 2011
I'm having trouble following your question. I have dealt with serial ports enough to know what to do if you want some sample code. Serial ports should be opened and closed only as needed. Disposal is critical or you will get port already opened errors. You also need to handle if your data doesnt all come in one read. It's all very tricky but if you set it up correctly you'll run into less problems.

JawnV6
Jul 4, 2004

So hot ...
I've completed half of this. The polling portion is working fine. I'm not having issues opening or closing ports?

All of my work so far has been controlling the code on the device itself. It sleeps, wait for a byte to come in from the PC, then replies back with data. For this, I can't control the code on the device. It is speaking to another module, then sends a message to the PC when that procedure is done. While this is happening I can't send anything to the device or electrical demons might burn it all down. I don't want to touch the existing polling loop. I want to set up a handler that scans for the end message and pass control back to the timer when it comes in.

It's not throwing any warnings when I'm reading and modifying the timer enable in the handler thread, so I'm pretty sure there's no issues there. I'm fighting the various flavors of Read to figure out which one's appropriate for the handler to use.

crashdome
Jun 28, 2011
I generally used ReadExisting() but I also used to have a sleep call for 650ms to make sure it all came over.

When I converted to async, I called ReadExisting multiple times until nothing was returned and appended the bytes to a buffer. I then would send the buffer to thread safe message queue for the UI or any other usage. The dataReceived handler seems to run on it's own thread automatically. Generally I would have flow like this:

OpenPort --> SendData -->{Start Timeout and Wait}--> DataReceived {Reset Timeout} --> ProcessBuffer --> SendToQueue --> ClosePort

and then the Queue would raise an event that there was a message available. If the port would hang, it would timeout and close the port.

Edit: I also had a program that you would manually open and close the port. It would check if either CTSHolding or DSRHolding were live to determine if someone pulled the cable and auto-close if so.

crashdome fucked around with this message at 23:02 on Aug 15, 2014

JawnV6
Jul 4, 2004

So hot ...
ReadExisting() kicks back a string. Since there are goofy non-ascii bytes, the string turns into a not-string and despite shoving "pass" in one side, .Contains("pass") won't detect the mangled "\0p\0a\0s\0s". I'm trying to use Read() with a specific byte count into an array and parse that. There's a variety of messages getting passed back and forth, I can't say anything safely, and must detect a particular message.

My favorite sp weirdness is ReadByte() kicking back a int :v:

crashdome
Jun 28, 2011
ReadByte will supposedly return a single byte and you can Tryparse it but, it's a lot of bloat. ReadExisting returns a string but, you can convert the string to bytes using Encoding if you know the protocol encoding.

Use Read(byte[] buffer, int offset, int count) if you want a byte array directly.

Handling this means you'll have to wait for a response and allow the thread to populate BytesToRead. It isn't weirdness as much as it is just sloppy implementation spanning all the way back to .Net 2.0

JawnV6
Jul 4, 2004

So hot ...
ReadByte does not return a byte. It returns an int. An explicit conversion is required, it will not compile without that conversion. I'm confused what TryParse would help here.

That Read() call is what I've been using on the polling side. Apologies that wasn't clear. I can control that message and how many bytes it is, no issues. Now what I'm seeing is that when I'm 'listening in' on the other two devices communicating and checking things inside the handler, sp.BytesToRead is all over the map. Run to run variation, sometimes I get 1 byte when the channel never sends only one byte. It's never a relatively clean blob like reading into a byte buffer.

I might have to do something like your earlier suggestion and just wait a while. I can get control back of the messages after the indeterminate wait for a pass, I might just go back to the polling, block the write when it might be unsafe, and let my existing stuff to snip messages and make sure I'm looking at the right window get it back on track.

Thanks for the help. Pretty sure I can crack this with enough time at this point.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
I've never really liked switching on/off timers if it wasn't necessary. It always seemed kind of janky to me. I would probably just leave the timer running and then perform some check in the callback to see if it should early return. That way you have control over any locking you might need to perform for the check, etc. instead of just depending on the timer's Enabled property.

NoDamage
Dec 2, 2000

NoDamage posted:

I am porting an iOS/Mac/Android app to Windows using WPF, and need a basic sanity check on our approach to dealing with the database. We are planning to use Entity Framework and SQLite to store the client-side data, which will then be displayed at runtime in various ListViews and TreeViews. It seems like the standard way of populating those ListViews and TreeViews is to use databinding, however it's not quite clear to me how to ensure that the ListViews/TreeViews continue to update when the EF objects they are bound to are updated/inserted/deleted in the database. In particular:

1. When the EF object itself has one of its properties changed, and I want the ListView to update with the new property. Searching on StackOverflow I get the impression that I would have to manually implement INotifyPropertyChanged for each property to get the bindings to fire, as the EF objects don't include this capability by default. Is this correct?
2. When one (or more) EF objects are updated in a background thread (that is syncing with a web service), what's the proper way to ensure those changes propagate to the UI? Because DbContexts aren't thread-safe, different contexts need to be used for populating the UI vs syncing in a background thread. Is there a way to merge changes from one DbContext to another?

(On iOS/Mac, Core Data's NSManagedObjectContext supports both of these use cases, and Android's ContentProvider/CursorLoader/CursorAdapter does something similar, I am basically looking for the WPF equivalent, if there is one. Also, I'm not particularly attached to Entity Framework if there happens to be a better way to achieve this.)
Bump, anyone have any thoughts on this?

I have since discovered that (1) is incorrect, as long as I bind to DbSet.Local and mark all of the properties as virtual, it will create proxies that dispatch property change events. Have not found a good solution for (2) yet, but I am starting to get the impression that people just Refresh() their data when changes occur out-of-band from the UI. Is there no better way?

crashdome
Jun 28, 2011

JawnV6 posted:

ReadByte does not return a byte. It returns an int. An explicit conversion is required, it will not compile without that conversion. I'm confused what TryParse would help here.

I meant that ReadByte returns a byte (as an Int). In otherwords, it is an Int from 0 to 255 but, you understood what I was saying without me saying it in that you would need to convert it back.

Edit: I see Byte.TryParse doesn't take Int - may have confused you there too. In any case, I meant explicit conversion (BitConverter or whatever)

crashdome fucked around with this message at 18:02 on Aug 16, 2014

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

NoDamage posted:

Have not found a good solution for (2) yet, but I am starting to get the impression that people just Refresh() their data when changes occur out-of-band from the UI. Is there no better way?

I'd say do this until you have a good reason not to (e.g. performance) since it makes the code a lot simpler. In most applications, you're just not going to run into that performance wall. Computers are faster than you think.

ljw1004
Jan 18, 2005

rum

Ithaqua posted:

Does anyone have any ideas about getting around SignalR's inability to have async event handlers? I'm working on something where I have my application's logic totally platform-agnostic and want to fire events when the internal state changes and needs to be pushed to clients, but SignalR can't handle async void methods.

I've seen that other people have suggested code snippets but I still don't understand the actual problem, Ithaqua.

It sounds like your app is running on the server. Periodically you want it to send out events to all the clients when an internal part of your app changes. Do you want your app to pause until all clients have received the event? Presumably not. Presumably you just want to fire-and-forget some kind of event.

And which part of SignalR exactly isn't handling async void methods? If everything really is just fire-and-forget, what are you awaiting?

raminasi
Jan 25, 2005

a last drink with no ice
I want to start a ridiculous, pie-in-sky side project to compile C# into this tiny other programming language that already exists (but is really, really terrible). Is Roslyn the place to start here?

Mr. Crow
May 22, 2008

Snap City mayor for life
If it's not .net I don't know what Roslyn would do but I'm am idiot so...

raminasi
Jan 25, 2005

a last drink with no ice
I basically need a C#-parsing frontend.

mortarr
Apr 28, 2005

frozen meat at high speed
I'm setting up a TFS 2013 server today, so we can finally get shot of VSS!

Scuzzywuffit
Feb 5, 2012

All right, so I think I'm missing something fundamental about child windows and garbage collection, and Google is leading me in circles. This question is probably dumb, but I've been wrestling with it for awhile now, so if anybody has any tips, I'd be incredibly grateful.

I have a BackgroundWorker taking care of a time-consuming process. In order to report progress back to the user, I made a ProgressWindow class. Essentially, I just wanted something like a MessageBox with a ProgressBar, so I didn't bother with creating a ViewModel for it or DataBinding. It just has some fields with getters and setters that update the requisite controls.

I can spawn a ProgressWindow along with my BackgroundWorker in my main window's ViewModel, and everything works fine. However, I'd prefer to handle the actual creation of the ProgressWindow in the View. I created some functions in the view to handle ProgressChanged and RunWorkerCompleted events in the View, and hooked the BackgroundWorker up to them, but when I do this, the ProgressWindow doesn't get garbage collected and my application won't shut down when all of the windows have been closed. Breaking in the debugger (and looking at it with a couple of memory profilers) show that my application's _appWindowList still has a root path to the window.

In attempting to figure out why this is, I've taken out most of my EventHandlers and commented out a bunch of code that holds references to the ProgressWindow. The only time I reference the ProgressWindow is in the event handling function in the view shown below:
code:
public void LinkProgressWindowToWorker(object sender, PayloadEventArgs<BackgroundWorker> e)
{
    if(e.Payload == null)
    {
        return;
    }

    ProgressWindow pw = new ProgressWindow();
    pw.ShowDialog();
}
All it does is create and show a new ProgressWindow, which I then close by clicking the X. The window still never gets garbage collected. The ProgressWindow itself handles no events, and has no DataBindings or CommandBindings. Is there something I'm missing here?

Any help would be greatly, greatly appreciated.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Scuzzywuffit posted:

All right, so I think I'm missing something fundamental about child windows and garbage collection, and Google is leading me in circles. This question is probably dumb, but I've been wrestling with it for awhile now, so if anybody has any tips, I'd be incredibly grateful.

I have a BackgroundWorker taking care of a time-consuming process. In order to report progress back to the user, I made a ProgressWindow class. Essentially, I just wanted something like a MessageBox with a ProgressBar, so I didn't bother with creating a ViewModel for it or DataBinding. It just has some fields with getters and setters that update the requisite controls.

I can spawn a ProgressWindow along with my BackgroundWorker in my main window's ViewModel, and everything works fine. However, I'd prefer to handle the actual creation of the ProgressWindow in the View. I created some functions in the view to handle ProgressChanged and RunWorkerCompleted events in the View, and hooked the BackgroundWorker up to them, but when I do this, the ProgressWindow doesn't get garbage collected and my application won't shut down when all of the windows have been closed. Breaking in the debugger (and looking at it with a couple of memory profilers) show that my application's _appWindowList still has a root path to the window.

In attempting to figure out why this is, I've taken out most of my EventHandlers and commented out a bunch of code that holds references to the ProgressWindow. The only time I reference the ProgressWindow is in the event handling function in the view shown below:
code:
public void LinkProgressWindowToWorker(object sender, PayloadEventArgs<BackgroundWorker> e)
{
    if(e.Payload == null)
    {
        return;
    }

    ProgressWindow pw = new ProgressWindow();
    pw.ShowDialog();
}
All it does is create and show a new ProgressWindow, which I then close by clicking the X. The window still never gets garbage collected. The ProgressWindow itself handles no events, and has no DataBindings or CommandBindings. Is there something I'm missing here?

Any help would be greatly, greatly appreciated.

Did you try disposing the window when you're done with it?

Scuzzywuffit
Feb 5, 2012

Ithaqua posted:

Did you try disposing the window when you're done with it?

It's inheriting from Window, which doesn't implement IDisposable, and only uses standard WPF controls. Is that something I need to implement myself? I hadn't thought so, but I am pretty new to WPF.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Scuzzywuffit posted:

It's inheriting from Window, which doesn't implement IDisposable, and only uses standard WPF controls. Is that something I need to implement myself? I hadn't thought so, but I am pretty new to WPF.

Oh, for some reason I thought that Window implemented IDisposable. Nevermind.

[edit]
You've tried manually invoking the garbage collector?

New Yorp New Yorp fucked around with this message at 00:00 on Aug 18, 2014

Scuzzywuffit
Feb 5, 2012

Ithaqua posted:

Oh, for some reason I thought that Window implemented IDisposable. Nevermind.

[edit]
You've tried manually invoking the garbage collector?

I haven't tried in code, but I've forced garbage collection in the profilers and the process kept running (and the window instances stayed in memory), yeah.

I can just set my application's ShutdownMode to OnMainWindowClose instead of OnLastWindowClose to circumvent that particular issue, but my main concern is that I'm leaking memory with each successive ProgressWindow created.

Edit: Thank you for your help, by the way. I've been tearing my hair out over this for like a week now, which is going to be really embarrassing if the fix is something trivial.

Scuzzywuffit fucked around with this message at 00:21 on Aug 18, 2014

Sedro
Dec 31, 2008
Windbg can tell you what exactly is keeping the object around. I posted an example in the last thread but I can't search posts...

NoDamage
Dec 2, 2000

Bognar posted:

I'd say do this until you have a good reason not to (e.g. performance) since it makes the code a lot simpler. In most applications, you're just not going to run into that performance wall. Computers are faster than you think.
Well, we're going to start with this for now, I just can't see it performing very well if every time a change comes along*, we need to re-fetch from the database, rebuild all of those EF objects, rebuild all of the view models, and update all of those bindings, just to update the UI. It just feels...wrong to me.

* Which is not terribly infrequent as we'll have a background thread listening for changes being sent from other devices.

Mr. Crow
May 22, 2008

Snap City mayor for life

Scuzzywuffit posted:

which is going to be really embarrassing if the fix is something trivial.

With me anyway, it seems like the more hair raising and obnxious the issue, the more likely it is to be something trivial I'm overlooking.

Probably worth asking a co-worker for a second set of eyes, or taking a break from it for a day (if possible).




Are you able to see if the window is actually closed when you think it is? If the window actually gets Closed() it should be enough to not worry about it, the framework will get rid of it when it's can.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Mr. Crow posted:

With me anyway, it seems like the more hair raising and obnxious the issue, the more likely it is to be something trivial I'm overlooking.

I once spent an hour combing through VS bug reports trying to figure out why my loving tests in one single file wouldn't run. My co-worker pointed out that my class wasn't public. :doh:

Rooster Brooster
Mar 30, 2001

Maybe it doesn't really matter anymore.

GrumpyDoctor posted:

I basically need a C#-parsing frontend.

Rosyln should be able to parse you out a syntax tree from C# text, and then you could build a translator that would take that tree and spit out the other language's code. Does that sound like what you're looking for?

raminasi
Jan 25, 2005

a last drink with no ice

Rooster Brooster posted:

Rosyln should be able to parse you out a syntax tree from C# text, and then you could build a translator that would take that tree and spit out the other language's code. Does that sound like what you're looking for?

It's a start. I'm realizing I haven't quite thought all this through enough.

raminasi fucked around with this message at 19:24 on Aug 18, 2014

Scuzzywuffit
Feb 5, 2012

Sedro posted:

Windbg can tell you what exactly is keeping the object around. I posted an example in the last thread but I can't search posts...

Thanks, I'll check it out! That's what I was hoping to get out of the profiler, but the strong reference in the Application's _appWindowList seems to be complicating things. If this works, I will be very grateful.

Mr. Crow posted:

With me anyway, it seems like the more hair raising and obnxious the issue, the more likely it is to be something trivial I'm overlooking.

Probably worth asking a co-worker for a second set of eyes, or taking a break from it for a day (if possible).




Are you able to see if the window is actually closed when you think it is? If the window actually gets Closed() it should be enough to not worry about it, the framework will get rid of it when it's can.

Yeah, I've spent enough time on this that I'm almost guaranteed to look like an idiot. This is unfortunately a solo project, so this thread was where I turned for extra eyes (although I didn't post all of the code, but still).

I've closed the window with a button whose action is assigned to the Close() method, as well as by just clicking the red X (which I'm assuming is the same thing). This doesn't seem to be sufficient, as the program remains open indefinitely even after all of the windows are closed.

IdentityMatrix
Apr 1, 2005
My identity is somewhat slanted...

Scuzzywuffit posted:

All right, so I think I'm missing something fundamental about child windows and garbage collection, and Google is leading me in circles. This question is probably dumb, but I've been wrestling with it for awhile now, so if anybody has any tips, I'd be incredibly grateful.

I have a BackgroundWorker taking care of a time-consuming process. In order to report progress back to the user, I made a ProgressWindow class. Essentially, I just wanted something like a MessageBox with a ProgressBar, so I didn't bother with creating a ViewModel for it or DataBinding. It just has some fields with getters and setters that update the requisite controls.

I can spawn a ProgressWindow along with my BackgroundWorker in my main window's ViewModel, and everything works fine. However, I'd prefer to handle the actual creation of the ProgressWindow in the View. I created some functions in the view to handle ProgressChanged and RunWorkerCompleted events in the View, and hooked the BackgroundWorker up to them, but when I do this, the ProgressWindow doesn't get garbage collected and my application won't shut down when all of the windows have been closed. Breaking in the debugger (and looking at it with a couple of memory profilers) show that my application's _appWindowList still has a root path to the window.

In attempting to figure out why this is, I've taken out most of my EventHandlers and commented out a bunch of code that holds references to the ProgressWindow. The only time I reference the ProgressWindow is in the event handling function in the view shown below:
code:
public void LinkProgressWindowToWorker(object sender, PayloadEventArgs<BackgroundWorker> e)
{
    if(e.Payload == null)
    {
        return;
    }

    ProgressWindow pw = new ProgressWindow();
    pw.ShowDialog();
}
All it does is create and show a new ProgressWindow, which I then close by clicking the X. The window still never gets garbage collected. The ProgressWindow itself handles no events, and has no DataBindings or CommandBindings. Is there something I'm missing here?

Any help would be greatly, greatly appreciated.

Not sure where that event handler is hooked up, but are you unhooking the event handler when shutting everything down? And have you tried pw.Show() instead of pw.ShowDialog() or would that impact the execution path?

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

IdentityMatrix posted:

Not sure where that event handler is hooked up, but are you unhooking the event handler when shutting everything down? And have you tried pw.Show() instead of pw.ShowDialog() or would that impact the execution path?

ShowDialog() vs Show() shouldn't make a difference in WPF. However, I bet there is still a dangling event handler somewhere around there.

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction
This is a sort-of .net question, but more of a xaml/winrt question. I have a Windows Phone 8.1 app, and I have a page with a listview using a wrapgrid for layout to display grid cells. I have a tap event hooked up in the item datatemplate, which triggers a frame navigation to another page. What I want to do is set up a page transition so that the effect achieved is similar to the Windows Phone start screen app-tap navigation, where the thing you tapped delays for a hundred milliseconds or so before sweeping away.

I looked at ContinuumNavigationTransitionInfo and CommonNavigationTransitionInfo (particularly whether IsStaggerElement would be the solution) and I cannot for the life of me figure out how to set this stuff up.

I also can't find any good tutorials and of course MSDN is terrible.

Essential
Aug 14, 2003
Can MEF be used to load & unload a library from a running application? I want to be able to silently update files while a system tray app runs.

I've done the same thing with a windows service and AppDomain, however I'm wondering if MEF is a better option.

I thought I read before that MEF cannot unload a library once it's loaded (without closing the app down of course), but now I can't find anything on that.

Essential fucked around with this message at 17:35 on Aug 19, 2014

Scuzzywuffit
Feb 5, 2012

IdentityMatrix posted:

Not sure where that event handler is hooked up, but are you unhooking the event handler when shutting everything down? And have you tried pw.Show() instead of pw.ShowDialog() or would that impact the execution path?

That handler is added to a ViewModel event, InitializeReporting. I believe I've tried removing it in the BackgroundWorker's RunWorkerCompleted event (I'll double-check though). If my understanding is correct, though, a subsequent raising of that event would reference a different ProgressWindow, so that event wouldn't have a strong reference to a particular instance?

Running a profiler shows an incoming reference to the window from a RoutedEventHandler, but I never hooked one up to the window; all the code that interacts with the window is shown above (I commented everything else out to try and solve this). Is there an event hooked up by default that could be causing an issue?

I tried switching to ShowDialog() because Show() wasn't working, so that's not it.

raminasi
Jan 25, 2005

a last drink with no ice
I'm using the built-in VS2013 profiler thing, and I'm seeing a bunch of time spent on a simple field read. As it turns out, the code to populate this field might be taking some substantial time to execute. I'm profiling a release build. Am I seeing the JIT or whatever defer the computation and assignment until the field is actually accessed?

raminasi fucked around with this message at 20:31 on Aug 19, 2014

Careful Drums
Oct 30, 2007

by FactsAreUseless
I have a problem: the default bundling in System.Web.Optimization is not cutting it.

I need to be able to pull down css/js/images from our own hosted CDN, bundle it up, then serve that as one minified request. I guess with System.Web.Optimization you can only pull down inidividual CDN files.

Anyone have experience or reccomendations on this?

The candidates so far are to

- use grunt and a poo poo ton of dependencies to host a static site with everything bundled already. I don't hate this but I'm hesitant to introduce node.js into our all-asp.net mvc workflow
- use this bundler library which is basically a wrapper for what i previously described
- this library called squishit which as far as i can tell looks okay. But I'm not so sure what the hell is going on with their AssetsController class in this example.

Paul MaudDib
May 3, 2006

TEAM NVIDIA:
FORUM POLICE
Simple question but one that's always bothered me: A lot of times, parameters passed to a constructor are literally just dumped into a class member verbatim. Even in Microsoft's examples we've got:

code:
public class Employee
{
    public int salary;

    public Employee(int annualSalary)
    {
        salary = annualSalary;
    }
}
Is there some way to say "you're going to be passed a value that should be assigned to class member salary" directly? I.e. equivalent in functionality to the above but looks more like this:

code:
public class Employee
{
    public int salary;

    public Employee(int this.salary)
    {   }
}

Adbot
ADBOT LOVES YOU

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Paul MaudDib posted:

Simple question but one that's always bothered me: A lot of times, parameters passed to a constructor are literally just dumped into a class member verbatim. Even in Microsoft's examples we've got:

code:
public class Employee
{
    public int salary;

    public Employee(int annualSalary)
    {
        salary = annualSalary;
    }
}
Is there some way to say "you're going to be passed a value that should be assigned to class member salary" directly? I.e. equivalent in functionality to the above but looks more like this:

code:
public class Employee
{
    public int salary;

    public Employee(int this.salary)
    {   }
}

C#6 will have this in the form of primary constructors. I'm sure someone will correct me if I'm wrong, but you'll be able to do:

code:
public class Employee(int salary) 
{

}
and it will generate a private field for the value, no explicit constructor necessary.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply