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
EssOEss
Oct 23, 2006
128-bit approved
Good to hear. What is the modern state of getting a nice-looking WPF app off the ground without major design effort? I remember there being some issues with the default visuals being rather bland and few meaningful 3rd party themes being available some years ago when I last used WPF. Has this improved?

Adbot
ADBOT LOVES YOU

ljw1004
Jan 18, 2005

rum

EssOEss posted:

Good to hear. What is the modern state of getting a nice-looking WPF app off the ground without major design effort? I remember there being some issues with the default visuals being rather bland and few meaningful 3rd party themes being available some years ago when I last used WPF. Has this improved?

Hari replied: We have not done any new out of box themes. We have added support for Windows 8.1 with a new Aero2 theme that is enabled when you are running on 8.1. Hope that helps.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

ljw1004 posted:

[plug] The WPF team wants to get the message out about work they're doing for WPF. In this case, they've brought the XAML-performance-analysis tools from WinRT XAML (VS2013) to also now work with desktop WPF XAML (VS2015 CTP5):

http://blogs.msdn.com/b/wpf/archive/2015/01/16/new-ui-performance-analysis-tool-for-wpf-applications.aspx

Neat! I'm always glad to hear that WPF is still being worked on (it being the one true .NET desktop framework and all).

While we're on the topic, is the WPF team planning to add any quality of life stuff? For me, it's nothing major, but in every WPF project I seem to always end up re-implementing certain classes that I feel should be provided by the framework. For example:

C# code:
public class ActionCommand : ICommand
{
    private readonly Action _action;
    private readonly Func<bool> _canExecute;

    public ActionCommand(Action action) : this(action, () => true) { }
    public ActionCommand(Action action, Func<bool> canExecute)
    {
        _action = action;
        _canExecute = canExecute;
    }

    public bool CanExecute(object parameter)
    {
        return _canExecute();
    }

    public void Execute(object parameter)
    {
        _action();
    }

    public event EventHandler CanExecuteChanged;
}
And also the ActionCommand<T> variant. This is also a common one:

http://stackoverflow.com/a/3128498/957673

There are a few others that I always end up using, but I can't think of them now since I haven't done a WPF project in a while.

wilderthanmild
Jun 21, 2010

Posting shit




Grimey Drawer
It always did seem a little silly to me that there weren't basic, pre-built implementations of INotifyPropertyChanged and ICommand included with WPF. There's plenty of reasons to want to build your own, but it's annoying to have to write a class implementing each in every WPF project I work on. There's plenty more that I implement in every project, but I can't imagine a proper WPF project that didn't use either of those.

I''m sure there is some justification of this, but it just seems odd to me.

Inverness
Feb 4, 2009

Fully configurable personal assistant.
What WPF needs is improvements to make easier those little things that it tends to make harder.

Want a modal dialog with MVVM? Go gently caress yourself.

View model binding from a context menu? Not a chance.

Bind to selected item on a tree view? Nope.

Also, doesn't it still use some old outdated XAML version?

raminasi
Jan 25, 2005

a last drink with no ice
I want to be able to use OneWayToSource bindings with read-only dependency properties.

Blasphemeral
Jul 26, 2012

Three mongrel men in exchange for a party member? I found that one in the Faustian Bargain Bin.
Hell, I'd just like it if events could bind directly to view-model without needing code-behind shenanigans. Seriously, how has that not been addressed in the ~eight years of WPF? I mean, yeah, there's triggers (if you know about them, and if you include an additional DLL with your project, and if you do a bunch of additional boilerplate code to make it happen) but seriously, events are already supported and a major part of C#. Why not take what's already there and make it intuitive?

In essence, this:

Inverness posted:

What WPF needs is improvements to make easier those little things that it tends to make harder...

Blasphemeral fucked around with this message at 20:11 on Jan 20, 2015

Spazz
Nov 17, 2005

Figured I would crosspost this here in case any of you have some suggestions. I'm running out of ideas and I have a feeling this is due to something lacking in the cmdlets for forcing NTLM authentication, and writing a wrapper for cURL isn't going to be a feasible solution.

http://stackoverflow.com/questions/27975936/new-webserviceproxy-failing-to-authenticate-with-ntlm

Space Whale
Nov 6, 2014
I'm making WebAPI controllers. Right now, our routing is done in the "{controller}/{action}/{id}" style.

One pathing that is now desired in one case is:

What They Want posted:

Foo/{FooId}/Bar/

"Return all Bars and if Foo has that Bar"

Is there any way to do this? Should I? Why not just do "Foo/Bar/{FooId}"?

Sedro
Dec 31, 2008
As far as whether you should, APIs like this are pretty common
pre:
GET /posts                  fetch all posts
GET /posts/16               fetch specific post #16
GET /posts/16/comments      fetch all comments for post #16
GET /posts/16/comments/7    fetch specific comment #7 for post #16

Space Whale
Nov 6, 2014
Just stumbled onto attribute routing, so there's that.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Space Whale posted:

Is there any way to do this? Should I? Why not just do "Foo/Bar/{FooId}"?

Just use attribute based routing. This is exactly what it was made for.

^ e;fb

Mr Shiny Pants
Nov 12, 2012
So, where's the HoloLens SDK? And does it work on .Net? :)

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

I'm getting a pretty generic error from connecting to a MSSQL server with my web app so I thought I'd pick youse guys' brains to see if anyone's come across it before. The error is:
Exception message: [DBNETLIB][ConnectionRead (recv()).]General network error. Check your network documentation

So googling around leads me to a lot of bitching about how generic and unhelpful it is but not much for remediation. This is the scenario:
There is a development server called ServerB that runs a web app. There are scheduled tasks that kick off every (interval) that cause ServerB to query an MSSQL 2008R2 server over OpenVPN (ServerA), take that query and turn it into XML.

The event occurs in ServerB's event log, but I can't find sign of any matching problem in ServerA's event log. Most of the troubleshooting I've seen around this is saying check cables, check network cards, etc. but this setup has been running smoothly for months now, and I doubt any physical/network infrastructure events have occurred since this started happening (Monday).

The one thing I did read that kind of made sense was suggesting bad re-use/recyles of connections (near the end, ignore that it's a Delphi question):
http://stackoverflow.com/questions/10755560/auto-recover-when-dbnetlib-connectionwrite-general-network-error-causes-ado-conn

So the way we do these database calls is a general function in a 'helper' file that is structured like so (for those worried about injection/etc. this thing is locked down to only accept connections from the OpenVPN connection):
code:
    Public Function GetMeTheDatas ExecuteSqlReturnDataSet(ByVal sql As String) As DataSet
        Dim dbConn As System.Data.OleDb.OleDbConnection
        Dim dbComm As System.Data.OleDb.OleDbCommand
        Dim dbDs As New System.Data.DataSet
        Dim dbAdapter As System.Data.OleDb.OleDbDataAdapter

        Dim appPath As String = HttpContext.Current.Request.ApplicationPath
        dbConn = New System.Data.OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("sqlConnection").ConnectionString)
        dbConn.Open()
        dbComm = New System.Data.OleDb.OleDbCommand(sql, dbConn)
        dbComm.CommandTimeout = Integer.MaxValue
        dbAdapter = New System.Data.OleDb.OleDbDataAdapter(dbComm)
        dbAdapter.Fill(dbDs)  <-- Event Log error points to this line on first entry,

        dbConn.Close()
        Return dbDs
    End Function
Which is then called in a page_load (e.g. ProcessXMLFiles1.aspx) like so:
code:
Dim buttes As New DataSet <-- Error layer 2 is here
buttes = GetMeTheDatas("procname 'buttes''")

(xml processing For...Each row in buttes.tables(0).rows goes here)
So, the thing is, I'm not sure why this is happening. The connection between the two is steady; according to the OpenVPN logs and network uptime tracking (We use pingdom) the two machines are constantly connected. Also the proc itself is not 'heavy' (about 30,000 rows max) in anyway, and it's not tied to any specific procedure/page either. I've seen this error intermittently only starting last Monday, and on a variety of operations that use the database (all SELECTs of one kind or another).

Anyone run into this or have any insight?

Lastly, here's the detailed text from the event:
Thread ID: 7
Thread account name: IIS APPPOOL\buttesbackend
Is impersonating: False
Stack trace: at System.Data.OleDb.OleDbDataReader.ProcessResults(OleDbHResult hr)
at System.Data.OleDb.OleDbDataReader.GetRowHandles()
at System.Data.OleDb.OleDbDataReader.ReadRowset()
at System.Data.OleDb.OleDbDataReader.Read()
at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) (line numbers and file names removed)

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Scaramouche posted:

So the way we do these database calls is a general function in a 'helper' file that is structured like so (for those worried about injection/etc. this thing is locked down to only accept connections from the OpenVPN connection):

Locking down connections to your SQL Server won't stop injection attacks.

What kind of hardware are these two servers running on? Are they on the same LAN or are they in different countries? How often do you see this error?

There's a lot of blabber on the internet about SNP (Scalable Networking Pack) in Windows Server that can cause problems with dropped packets under high load if the network cards aren't up to snuff. In any case, if this happens intermittently and your servers aren't on the same LAN (or are hosted on VMs), it could be a transient network error. You could trying adding some retry logic in your Execute method.

wwb
Aug 17, 2004

I would strongly suspect network issues -- such as saturation -- here. I've seen this sort of thing and every time it traced back to either flaky network hardware or network saturation. That was a little more impressive in some of these cases but I'd suspect it would not take much to saturate one side of this open vpn connection. Unfortunately Sql Server's native protocol isn't the greatest at crossing WANs and tends to error out rather than retry a-la-http.

I would architect around the problem -- one thought would be to expose sql server's http interface and then have the app communicate with that. Http should be able to deal with network issues sql's binary protocol can't and you'd still get XML at the other end.

PS: why oledb? I'd use the native drivers as they might be more bulletproof there.

mastersord
Feb 15, 2001

Gold Card Putty Fan Club
Member Since 2017!
Soiled Meat

Scaramouche posted:

DB Connection error

I noticed you create a new connection and other ADO objects every time you connect. I set up a connection pool (we have multiple databases) and reuse oledbconnection objects. I am not sure which is better, as I am in no way an expert in how ADO works.

If you have access to your database server and a copy of SSMS, check the activity monitor for excess connections and/or other activity in excess.

I am too familiar with that error message, even in my VB6 apps. It almost always means something wrong with either the user's network connection, or the database server it's self.

gariig
Dec 31, 2004
Beaten into submission by my fiance
Pillbug

mastersord posted:

I noticed you create a new connection and other ADO objects every time you connect. I set up a connection pool (we have multiple databases) and reuse oledbconnection objects. I am not sure which is better, as I am in no way an expert in how ADO works.

Don't do this. ADO.Net is already doing connection pooling. The only reason to do your own object pooling is if you are having trouble with GC and creating/destroying a new object is too expensive (generally not).

A "General network error. Check your network documentation" is something of a legend. Every person who has solved this has a different way. I think Richard Campbell from .NET Rocks/Runas Radio once said it was a bad keystone jack. You can check out Polly about handling and retrying because of the transient error

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Thanks for all the good info guys; I figured it was something like that (incredibly generic error) that some of you had come across before. Some answers to people's questions:

The server info:
ServerA - Actually a repurposed desktop sitting under my desk, all it does is generate XML; it's not public facing or anything, just has scheduled tasks fire off that make calls into web pages. So basically it's running IIS and that's it. Q6600 @ 2.4 GHz processor and 4gb of RAM.
ServerB - Oldass Dell rack server we're in the process of clouding out. Runs IIS and MSSQL. Xeon 2 quadcore 3.2 GHz 8gb RAM.

Location: ServerA is in the office, and ServerB is in the colocation facility about 20 kilometers away; they are not in the same LAN. ServerB is running an OpenVPN listener that ServerA connects to.

Error frequency: About once or twice a day, usually first thing in the morning (which makes sense because that's when XML is being generated).

OLEDB vs Native: Haven't even thought of it to tell the truth. Is there somewhere that lists the differences between them?

Activity Monitor: This is a Good Thing that I forgot about. Problem being, I'm not 100% sure on how read the results. I'm currently concentrating on 'Recent Expensive Queries'. There's one with a plan count of 13,000 which seems high; it's basically a proc that goes 'SELECT * FROM Product WHERE Productid=@Productid' to help build and XML file about products (about 100,000 products).

wwb
Aug 17, 2004

If you've got IIS on server B I'd just push the app over there and eliminate the network angle. Keep Fowler's 1st law in mind.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

wwb posted:

If you've got IIS on server B I'd just push the app over there and eliminate the network angle. Keep Fowler's 1st law in mind.

That's actually what it was like originally, but was causing load problems because ServerB is a full blown web server handling tens of thousands hits a day. The 'brute' crunch was string handling, not database operations, so I moved t hat off to ServerA.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

gariig posted:

Don't do this. ADO.Net is already doing connection pooling. The only reason to do your own object pooling is if you are having trouble with GC and creating/destroying a new object is too expensive (generally not).

Seconding this. Don't pool your own OleDbConnections, it's a waste of time and effort.

Also, if you're having trouble with GC (and you're almost assuredly not), OleDbConnections are not going to be the cause of your problems.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer
This is more a Visual Studio question than a .net question, but this seems the closest place to ask.
Is there a way to add C as a project type to VS2013? My Intro OS-es class is taught in C and I don't really want to give up my IDE creature comforts to code in Vim or Notepad++ or something. That was enough of a bitch doing basic stuff in Java and I'd rather devote my limited time/brainspace to learning the actual material than loving around debugging things and syntax-tweaking without a good IDE.

Shy
Mar 20, 2010

LeftistMuslimObama posted:

This is more a Visual Studio question than a .net question, but this seems the closest place to ask.
Is there a way to add C as a project type to VS2013? My Intro OS-es class is taught in C and I don't really want to give up my IDE creature comforts to code in Vim or Notepad++ or something. That was enough of a bitch doing basic stuff in Java and I'd rather devote my limited time/brainspace to learning the actual material than loving around debugging things and syntax-tweaking without a good IDE.

I don't know about project types but if you create an empty C++ and add *.c files instead of *.cpp they are supposed to be compiled as C.

raminasi
Jan 25, 2005

a last drink with no ice
Under "Code Generation" you can also just set the whole project to be compiled as C. And make sure you create an "Empty project," or else a bunch of other stupid garbage will be included.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

Shy posted:

I don't know about project types but if you create an empty C++ and add *.c files instead of *.cpp they are supposed to be compiled as C.
sweet! I just wasn't sure if any ms specific header and library sort of stuff was around to com fuse me. ultimately we have to target gcc on red hat 6.

ed tablet posting' still betting used to typimg..


Edit with keyboard: Holy crap, MS has a ways to go on their autocorrect for the Surface's touch keyboard!

The MUMPSorceress fucked around with this message at 16:35 on Jan 23, 2015

Mr Shiny Pants
Nov 12, 2012

Scaramouche posted:

That's actually what it was like originally, but was causing load problems because ServerB is a full blown web server handling tens of thousands hits a day. The 'brute' crunch was string handling, not database operations, so I moved t hat off to ServerA.

Buy a new server? I don't want to sound like a dick or anything but I just bought a Lenovo Thinkserver with 4 core HT Xeon with 32GB of ram for less than 1000 euro's.

I mean, if it's an important application a new rackserver is not that much of an investment these days.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Mr Shiny Pants posted:

Buy a new server? I don't want to sound like a dick or anything but I just bought a Lenovo Thinkserver with 4 core HT Xeon with 32GB of ram for less than 1000 euro's.

I mean, if it's an important application a new rackserver is not that much of an investment these days.

No I get you, the problem being we want this server to eventually not exist and are in the process of offloading everything on it into VMs and Cloud Storage, and therefore don't want to invest in further infrastructure. I've just got to baby this along until we finish switching over.

As for the error, uggh it happened over a dozen times yesterday. I uploaded a new code base last night that has optimized a lot of the high plan count queries and today I'll be working on the high execution time ones. I've also put a network monitor on ServerA to see if the network card is getting over-saturated when these errors happen so we'll see how that goes.

raminasi
Jan 25, 2005

a last drink with no ice
If I need to kick off a long-running, CPU-bound task and not care about the results, is just calling Task.Run(whatever) the right way to do it?

gariig
Dec 31, 2004
Beaten into submission by my fiance
Pillbug

GrumpyDoctor posted:

If I need to kick off a long-running, CPU-bound task and not care about the results, is just calling Task.Run(whatever) the right way to do it?

Yes but don't have the implementation call Task.Run have the caller (here's why). Just remember you won't get any exception messages unless the code in the Task handles it. It's truly fire and forget if the task isn't awaited.

If you are in ASP.NET you are sucking up a thread from your thread pool that is used to handle requests and IIS might shut down your app while it's running. You can use QueueBackgroundWorkItem to get around that or ship it off the box.

gariig fucked around with this message at 22:05 on Jan 23, 2015

Mister Duck
Oct 10, 2006
Fuck the goose

GrumpyDoctor posted:

I want to be able to use OneWayToSource bindings with read-only dependency properties.

How recently have you tried to do this and with what version of .NET?

ljw1004
Jan 18, 2005

rum

Mr Shiny Pants posted:

So, where's the HoloLens SDK? And does it work on .Net? :)

The only answer at the moment is "please wait for HoloLens at BUILD" and "everything you learn about developing for Windows will help you get ready to develop for Microsoft HoloLens":
http://www.microsoft.com/microsoft-hololens/en-us/get-ready

Mr Shiny Pants
Nov 12, 2012

Scaramouche posted:

No I get you, the problem being we want this server to eventually not exist and are in the process of offloading everything on it into VMs and Cloud Storage, and therefore don't want to invest in further infrastructure. I've just got to baby this along until we finish switching over.

As for the error, uggh it happened over a dozen times yesterday. I uploaded a new code base last night that has optimized a lot of the high plan count queries and today I'll be working on the high execution time ones. I've also put a network monitor on ServerA to see if the network card is getting over-saturated when these errors happen so we'll see how that goes.

One thing I found when using VPNs is that MTU sizes and packets might get all messed up. It might be that your firewall drops large packets or fragments them and the other end can't fix them up. I don't know if you can set the MTU size for the SQL libraries but it might be worth checking it out. Especially as it seems to happen with larger queries ( or is this something that I am assuming? ). There are some KB articles that mention this with Group Policy not working over VPN tunnels.

More info: http://community.spiceworks.com/topic/217130-mtu-issues-in-vpn-connections

ljw1004 posted:

The only answer at the moment is "please wait for HoloLens at BUILD" and "everything you learn about developing for Windows will help you get ready to develop for Microsoft HoloLens":
http://www.microsoft.com/microsoft-hololens/en-us/get-ready

Cool, can't wait! :)

Inverness
Feb 4, 2009

Fully configurable personal assistant.
The HoloLens thing is fantastic. Now if only they could shrink it to the size of a normal pair of glasses.

gariig posted:

Yes but don't have the implementation call Task.Run have the caller (here's why). Just remember you won't get any exception messages unless the code in the Task handles it. It's truly fire and forget if the task isn't awaited.

If you are in ASP.NET you are sucking up a thread from your thread pool that is used to handle requests and IIS might shut down your app while it's running. You can use QueueBackgroundWorkItem to get around that or ship it off the box.
How does this apply to something like network communication?

I have a WPF client application with a service interface containing something like Task<Data[]> GetDataAsync(). This is implemented as a call to Task.Run() on a private GetData() which does the actual network communication with WCF asynchronously.

This seems proper. Making the service-user invoke Task.Run() seems like it would bloat my code and imply that there is every a case where you shouldn't be having that executed asynchronously.

Inverness fucked around with this message at 04:42 on Jan 24, 2015

ljw1004
Jan 18, 2005

rum

Inverness posted:

How does this apply to something like network communication?

I have a WPF client application with a service interface containing something like Task<Data[]> GetDataAsync(). This is implemented as a call to Task.Run() on a private GetData() which does the actual network communication with WCF asynchronously.

This seems proper. Making the service-user invoke Task.Run() seems like it would bloat my code and imply that there is ever a case where you shouldn't be having that executed asynchronously.

There is indeed a common case where you shouldn't be doing that... Users of your GetDataAsync won't even know that it uses Task.Run. They'll be mislead by its signature into believing its a "truly async" and hence lightweight call, whereas actually it's a fake async call that looks async but isn't really async under the hood.

We encountered this within VS itself. Other folks in teams within VS would use Task.Run internally in their components to handle network and disk activity exactly like you're doing and the rest of us wouldn't know. The problem is that the threadpool only grows at a rate of about 1 thread per second. So we'd get situations where every thread in the threadpool was busy doing Task.Run for network/disk access, and the IDE needed just one small brief thread to quickly compute what intellisense to show after the user types "dot", but all of VS would mysteriously hang for 1 second until the threadpool granted us another thread or until a piece of network/disk activity finished. The way we improved typing responsiveness (and made C#/VB more responsive in VS2015 than in VS2010, VS2012, VS2013) was by ruthlessly eliminating every internal call to Task.Run, so only the "top level" components within VS are allowed to decide when and how to use the threadpool.

I made a short tutorial video on this subject: http://channel9.msdn.com/Series/Three-Essential-Tips-for-Async/Async-Library-Methods-Shouldn-t-Lie

ljw1004 fucked around with this message at 05:25 on Jan 24, 2015

raminasi
Jan 25, 2005

a last drink with no ice

Mister Duck posted:

How recently have you tried to do this and with what version of .NET?

6-9 months ago and with .NET 4.0, I believe. Did it get fixed? That's great.

Che Delilas
Nov 23, 2009
FREE TIBET WEED

Oh, you're Lucian Wischik? Your async tips and tricks videos, particularly the first three, really helped me get a handle on Async (at least, they got me past the first hump which was understanding the program flow when async and await are in play). Great stuff.

Inverness
Feb 4, 2009

Fully configurable personal assistant.

ljw1004 posted:

There is indeed a common case where you shouldn't be doing that... Users of your GetDataAsync won't even know that it uses Task.Run. They'll be mislead by its signature into believing its a "truly async" and hence lightweight call, whereas actually it's a fake async call that looks async but isn't really async under the hood.

We encountered this within VS itself. Other folks in teams within VS would use Task.Run internally in their components to handle network and disk activity exactly like you're doing and the rest of us wouldn't know. The problem is that the threadpool only grows at a rate of about 1 thread per second. So we'd get situations where every thread in the threadpool was busy doing Task.Run for network/disk access, and the IDE needed just one small brief thread to quickly compute what intellisense to show after the user types "dot", but all of VS would mysteriously hang for 1 second until the threadpool granted us another thread or until a piece of network/disk activity finished. The way we improved typing responsiveness (and made C#/VB more responsive in VS2015 than in VS2010, VS2012, VS2013) was by ruthlessly eliminating every internal call to Task.Run, so only the "top level" components within VS are allowed to decide when and how to use the threadpool.

I made a short tutorial video on this subject: http://channel9.msdn.com/Series/Three-Essential-Tips-for-Async/Async-Library-Methods-Shouldn-t-Lie
This is pretty helpful, thanks.

In that case, my next question would be if there is any way to wrap a synchronous WCF service call in a Task that is properly async?

I believe its possible to generate async methods for WCF services nowadays, but I am using the existing libraries used on the server rather than generating my own.

I know I can ultimately not worry about this and just leave the async up to the top level component, as you suggested, but I'm curious.

Inverness fucked around with this message at 17:23 on Jan 24, 2015

ljw1004
Jan 18, 2005

rum

Inverness posted:

In that case, my next question would be if there is any way to wrap a synchronous WCF service call in a Task that is properly async?

No, unfortunately not. "It has to be turtles all the way down" :)

Adbot
ADBOT LOVES YOU

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost
So Xamarin switched to Slack from Hipchat. There's no official Windows Phone client yet (They are actually making one though, which shocked me) nor a Windows 8 version, so I figured I would start making one. If only as an excuse to play around with WebSockets.

I have the connection set up with MessageWebSocket and it's sending and receiving messages successfully. I have a timer set up so it can ping the server so it can maintain a connection, and close it when the view pages, or if there is a network issue. But I'm having an issue trying to figure out how to handle the messages I'm receiving. If you look at their API, it returns messages as JSON. That's great, but I like to deserialize json as objects with JSON.NET, and the objects it brings back can be different. For example

JavaScript code:
{
    "type": "message",
    "ts": "1358878749.000002",
    "user": "U023BECGF",
    "text": "Hello"
}
or

JavaScript code:
{
    "type":"user_typing",
    "channel":"C03C6CWAM",
     "user":"U03C6CW9T"
}
When I make API calls directly, I know exactly what I'm going to get back; The object I requested, or an error object. I don't think I can deserialize this directly though, so I can only parse it as a JObject, check the type field and go from there. Is there a good way to handle this, or am I just missing something obvious?

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