Browsing 7239 questions and answers with Jon Skeet

ISynchronizeInvoke missing in System.ComponentModel

I need to implement ISynchronizeInvoke interface in UWP app. Even with using System.ComponentModel; it says type or namespace ISynchronizeInvoke could not found. Does anyone know...
Jon Skeet
people
quotationmark

Use SynchronizationContext instead, basically. That's the more modern replacement for ISynchronizeInvoke. more 11/3/2015 6:50:19 PM

people

Using CreateInstance in Windows 10 Universal Apps

The following code doesn't compile in a Windows 10 Universal App, but does in a .Net console app (both using Reflection): string objType = "MyObjType"; var a =...
Jon Skeet
people
quotationmark

Reflection in CoreCLR / Windows 10 etc has moved quite a lot of what used to be in Type into TypeInfo. You can use IntrospectionExtensions to get the TypeInfo for a Type. So for example: using System.Reflection; ... var asm =... more 11/3/2015 6:35:07 PM

people

It does not appear to be a valid archive (Byte array to zip file in c#.net)

I am facing issue while converting byte array to zip file.Even though zip file is created using the below code but when I am extracting the zip file I am getting error "Cannot...
Jon Skeet
people
quotationmark

A GZipStream isn't a zip file, basically - it's a gzip file. That's just compressed data, without any notions of multiple files, file names etc. If you save the file as foo.gz you may find that the zip tool you use knows how to decompress... more 11/3/2015 1:21:23 PM

people

Force semaphore to use Java 8

I have an sbt project which needs Java 8 to run. But the SemaphoreCI keeps running it in Java 7 and it fails: [error] java.lang.UnsupportedClassVersionError:...
Jon Skeet
people
quotationmark

The Semaphore Java documentation tells you how to do this: Switching between Java versions is done by adding the following command to your build commands: change-java-version <version> Valid values for <version are 1.7... more 11/3/2015 7:06:15 AM

people

How to load interstitial ads in adview

I am referring this google tutorial to place interstitial ads in my app, https://developers.google.com/admob/android/interstitial. I am able to successfully show banner ads in...
Jon Skeet
people
quotationmark

I think this may be the problem: if (interstitial != null && interstitial.isLoaded()) { interstitial.setAdListener(new AdListener(){ public void onAdLoaded(){ interstitial.show(); } }); }... more 11/3/2015 7:02:10 AM

people

Android check if value equals to the values in Array

I have a ArrayList tokens; I am adding values to the array with a listView click. Before i add the value to array i check if the value already exist array. I remove the value is...
Jon Skeet
people
quotationmark

If your list is empty, you never go into the loop, so you'll never call add. If you do have any tokens to start with, you're either adding or removing the new token for each existing token which isn't what you want. I suspect you... more 11/2/2015 1:57:03 PM

people

Why does the new Java 8 Date Time API not have nanosecond precision?

One of the features of the new Date Time API in Java 8 is supposed to be nanosecond precision. However when I print the current Date Time to the console like so DateTimeFormatter...
Jon Skeet
people
quotationmark

The java.time API in general does have nanosecond precision. For example: DateTimeFormatter formatter = DateTimeFormatter .ofPattern("yyyy-MM-dd'T'HH:mm:ss,nnnnnnnnnZ"); OffsetDateTime odt = OffsetDateTime.of(2015, 11, 2, 12, 38, 0,... more 11/2/2015 12:39:39 PM

people

RestSharp changes timezone on serialization

RestSharp changes the timezone on my datetime-objects during serialization. The original datetime object is for example 2015-01-02 00:00:00 when I debug, but when RestSharp...
Jon Skeet
people
quotationmark

Well if you're happy getting "midnight at the start of the given date, in UTC" you can use: if (!string.IsNullOrEmpty(fieldData) && DateTime.TryParseExact( fieldData, "yyyy-MM-dd", ... more 11/2/2015 8:20:51 AM

people

Print result of java version to file > Why is resulting file empty?

java -version correctly prints Java version. java -version >> test.txt creates an empty file. My problem is that WScript.Shell has exactly the same behavior (empty string...
Jon Skeet
people
quotationmark

java -version displays the version information on standard error rather than standard output... so you need to redirect that: java -version 2>> test.txt Here the 2>> means "redirect standard error, appending it to the given... more 10/31/2015 4:03:11 PM

people

Lap time formatting code is confusing

I have this code from school and I can't seem to understand exactly what is it doing. I know it shows a lap time, like those from sports, converted in a minutes, seconds and...
Jon Skeet
people
quotationmark

Firstly, this is really bad code in my view. It's converting the original ms value into a string (so 35968 would become "35968") and then parsing that into a Date, as if from a format which only specifies a number of milliseconds... which... more 10/31/2015 8:47:43 AM

people