« first day (1682 days earlier)      last day (3249 days later) » 

4:42 AM
 
 
3 hours later…
8:01 AM
whad up bitches
 
8:15 AM
holiday here, whooo
 
here too
 
8:38 AM
here too, I hope at least
nope not in Ireland
 
Hi
Could someone help me with BlockingCollection<> ?
Could I wake up the .Take() action from BlockingCollection ?
I have one thread that insert items very fast and another thread that do .Take() nad the problem is that 20 inserts is only 1 take :(
 
Never used it. My hunch though is that it's doing exactly what it's designed to do - if you have a thread that calls Add() frequently, it'll - ta da - block
Take()'s caller therefore has to wait a lot.
Are you asking whether you can tune those threads so that Take() gets blocked less often?
 
8:58 AM
yes
 
sigh, debugging databinding issues is fun
 
I mean at some point from the beginning I know that I already put item in collection but I can not see the .Take() lock is wake up to take this item :(
I try all of them .TryToTake() .Take() .GetConsumerEnumerable() - everyone is 'waiting' too long
 
@Jasper perhaps you could batch up the adds and perform Add() on a timer
 
No - I cant' :( those items is a stream from hardware device and they coming whenever they want :( I have not control of it
 
OK, is rapid handling of those items important or can you induce a slight delay?
 
9:03 AM
There's no problem if I have a little gap in-between receiving, a little delay -> then all the 'waiting' threads is wake up collect the item and continue to work. But if adding thread is pushing tooo fast it take a lot of time for other threads to wake up
the order of incoming events is important
may be I should post a question to SA ?
 
If you're receiving events faster than you can process them, that's a fundamental problem
which site is SA?
 
*SO - StackOverflow
What is design pattern from on thread .Add() item and multiple threads .Take() item ?
I thought it BlockingCollection
*on = one -> One thread putting items and multiple thread take items
 
I don't have a lot of experience in that. It will have to depend on what algorithm you're performing
 
Mmm... the algorithm implemented in BlockingCollection<> - it's already have all necessary 'locks' and other things to balance the incoming and outgoing data
But may be I'm wrong....
I should post a question to SO
 
9:20 AM
You don't have to lock to do things on multiple threads, necessarily. You just have to make sure the algorithm still gives the right answer whatever order the items are processed in. If result t+1 gets produced before result t, maybe you have to throw message t away because time has moved on
For example
 
I can not 'drop' items from stream :(
The problem is not in 'process' the problem is balance the .Add() and .Take() synchronization
on the other end of this 'process' is linear, on threaded function that will receive 'item' save it to the file. This function could take a lot of time - so I make a 'buffer' that store all incoming 'items' to collection and the on-thread-slow function could process them one by one in it own time
*on = one -> one thread function
 
This question looks like it covers this problem stackoverflow.com/questions/19131772/…
OK, how long will that process be going on? You can't run it indefinitely, if the consumer is slower than the producer. The queue will fill forever until you run out of memory
And yes, if you're involving the disk I don't think it makes sense to have more than one thread writing. The disk has a maximum throughput and trying to share it between threads would just make it slower. Do you have to do any processing to the items or just take them and serialize them?
 
9:41 AM
Yes - I known that I have a memory issue. Everyone agree that I try my best to .Dispose() the items but everyone knows about it and agree. (there will be some barriers later) -> currently memory is not a problem
yes - the somewhere in the chain the 'item' processed and at very end is serialized
 
What do you have that requires Dispose()?
 
?? the 'item' itself
 
Isn't that just an instance of a CLR type?
What do you think Dispose() does?
 
Dispose() does ? I mean the 'item' temporarily hold logical structure that mean something for 'steps' in process but whenever it written to disk it should be disposed
The 'steps' itself does not create more 'items' it just 'route' it to correct next-step
 
What do you think the Dispose method is for?
 
9:45 AM
Dispose() method signal the GC that this object should be disposed
but according to the latest Eric Lipperts article I'm not sure now
 
No, it doesn't. The GC can figure that out on its own. IDisposable is meant to clean up system resources, like file handles, GDI brushes etc - things that the system has a finite supply of. You're supposed to write a Dispose method that cleans up those things if you use any of them, and implementing IDisposable is a hint to the programmer to make sure they do that when they're finished with it
Any sensible IDisposable class will have a finalizer that cleans them up anyway, and the GC calls that finalizer when it finalizes an object, but for good performance you're meant to do that yourself instead of making the GC do it for you
 
so - what about Dispose() ?
 
Implementing IDisposable on a pure .net class does absolutely nothing
 
Ok
 
Well. That's not quite true. A few types use it for some special logic
 
9:51 AM
Its promoting IDisposable by providing using. The idea is to ensure you cleanup unmanaged memory, rather than relying on destructor.
 
Rx subscriptions are IDisposable for example. And they use it to signal 'stop consuming messages'. I think I've read a blog somewhere where a framework dev argues that was a bad design decision
 
I guess there's a disposable object chain somewher in GC and you .Dispose() method WILL be called - so it's not line 'absolute nothing'
 
@Jasper the GC doesn't call Dispose() for you
 
Try to read Eric Luppet article -> it about disposing: ericlippert.com/2015/05/18/…
 
I've read it
 
9:52 AM
Friends, I am looking for parsing a string to reflection methodname. Can you help me with some link ?

The requirement is global::ABC.XYZ.MyClass.MyMethod() in string should give me the methodInfo object.
 
Ok - if we both read it let's concentrate on BlockingCollection - shall we ?
@abhishek .. in string... ??
 
I have a Drag&Drop implementation between 2 listviews. The problem is the item is getting added whenever i drag over the dropzone, adding the same item multiple times. How can I check if the mousebutton is released or clicked?
 
yes @Jasper, its in string, and need to parse namespace, class and then find methodname
 
??? You want a name of the method or ... I don't understand what is it: ..in string.. -> you mean 'as text' ?
or you have a String str = new string () object ?
There's something wrong in Drop() implemetation
Item should not be added multiple times
 
no, I want the MethodInfo object so that I can invoke the method. Actually the entire string is stored as data and I need to convert it and call it
 
9:57 AM
the Drag-and-Drop implemetation itself checks Mouse realease and click events
 
for example :

System.DateTime.Now should give me Getter MethodInfo of Now so that I can call it
 
this is behavior of Drag-and-Drop
 
where System.DateTime.Now is stored as string
 
hmmm... why you converting it back and forth ? you already have a MethodInfo object
but it does not matter
just check you Drop() implementation
it called once
 
no, actually I want the user could input static method and I want to execute it
user will input as string
 
10:03 AM
user will input ad-hoc string/text and you will execute it ? Sounds misleading...
or dangerous
 
no actually I am doing dynamic stuffs where the user defines filter in cloud and that will be getting executed in Agent running in their own machine. During filter definition, currently they can call a method which we give permission to. for that I need to define all the methods that they can call. But the problem now, I want to automate this so that people can write any method in filters for instance String.Concat, DateTime.Now etc
 
@abhishek I looked for some sort of built-in method that can parse that string, I can't find one. I suppose what you could do is split that string on the final dot, take the left as the typename and the right as the name of the method
Type.GetType(leftPart).GetMethod(rightPart) or something along those lines
 
yes.... that is something I have been doing right now. But the problem is say there is a nested type say Namespace.Type1.Type11Nested.Method
 
I don't know how nested typenames are represented, that might actually be right?
but I guess since you're asking, it's not
 
@abhishek You see - in your implementation you don't know if the method exist until you come to actually execute it. That's ok if: 1) You didn't write a buggy code that look for a actual method (if you miss something user input never execute although it exist) 2: You must work very hard and train you user what text they allow or not to input
 
10:12 AM
no. I havent tried that. It is working already using Type.GetType, just I am thinking whether this can create problem or not with nested types
 
2) work very hard to convert they string to please .NET reflection system
another solution it back-forward solution: You scan and prepare all 'callable' methods with all the 'rules', security, etc.. you want
 
^^ Yes, users will screw it up so robust error handling is essential. From the problem description I guess these will be mostly developers or sysadmins so maybe comprehension of .net type and method names isn't unreasonable
 
they make a combo-box with all the methods and let the user choose
 
yes... actually if I cannot parse the method, I am returning blank string as response.
hmm. Previously it was like only the methods we allow, they can define. The target user is totally .NET developers in cloud portal
thats why I am trying to extend
 
10:27 AM
@abhishek Not sure if you have a right design.. For example - what about exceptions ? The method user called is throwing - who gonna catch this ? UI ? Logger ? How do you know if this is 'Ok' or not Ok to call this method in current circumstances ?
May be you should 'prepare' your data before user can choose from it
but hey - it's your design.. may be it's ok in your requiremenets
 
I have a Grid with multiple Rows. One Row contains a ListView which has many items. Right now the ListView takes up all the space, instead of using the space given with a scrollbar. Any idea what i'm doing wrong?
 
Sorry - don't know about Reflection issue
@BenjaminDiele Mmmm... Obviously you should .Hide the scroolbar and make content not-scroolable
 
Hello everyone
Can anyone please help with this question
0
Q: Make AI Bot that can test level - Unity3D

Ajay VenkatI was making a game and I wanted to create an AI bot which could simulate key presses and when it fails it retries and it notes on how it failed last time and corrects its self. I sat up last night writing this code but I doesn't work at all. using UnityEngine; using System.Collections; using Sy...

 
@Jasper Its ok Jasper.
 
@Jasper it's the other way around. There's isn't a scrollbar appearing
 
10:39 AM
@Xcoder - You make a lot of mess :) Just slow down a little bit :) What you need is object that could 'record' bot action and get result of this action. It's object number 1. If you need a miltiple 'actions' you could organize the 'Recorder' objects as LinkedList Then you need a way to interact with 'target' of action to get the result. And at the very end you need a Random to choose an action that gonna be executed
@BenjaminDiele No scroolbars ? May be you stack the Grid with elements with fixed size ? Try to use Auto or * sizes
 
@Jasper My GridDefinitions are all Auto, except the last, which uses *
 
You Grid.ActualWidth is bigger than Window.ActualWidth'... Something is holding the space...
As i quick fix try to wrap the Grid with ViewBox
GridColumnDefenition is resized to the ActualWidth of internal elements
Mmm.. Or you want your Grid to expand the size of the Window ?
 
I'll upload my images, hang on
So the first image is when I open my window. The Second is when I resize it so that every item is visible
 
hey
 
10:56 AM
Why don't I get a scrollbar? Instead WPF just cuts off :(
 
@BenjaminDiele If you want the context to scrool - Add/Allow scroolbars for Grid, Doesn't want to scrool - Add ViewBox around Grid. Part of grid scroolable - Change Grid to Listview or use ListBox in Grid with custom ItemTemplate
 
11:19 AM
@BenjaminDiele I don't want to rent.
 
@RoelvanUden shhh
 
@BenjaminDiele Make it a scrollview.
Yu could also set a resize mode and disallow resizing
because fuck users wanting to resize
 
@RoelvanUden first food time :D
 
 
1 hour later…
12:25 PM
@BenjaminDiele TIL Dutch is just English with random letters stuck in.
 
1:05 PM
@RoelvanUden Do you mean a ScrollViewer? Can't put an ItemsSource to that it seems.
Well, fixed it by putting margins manually. FrendallKey won't like me but it works for now
 
 
1 hour later…
2:13 PM
@BenjaminDiele put a panel in it
or an itemscontrol
 
 
3 hours later…
5:17 PM
@KendallFrey
o/
 
Back from *stan @KendallFrey?
 
5:44 PM
Quick question on XML Serialization, getting some weirdness I've never seen:
class Person
{
  public string[] name {get;set;}
public int Age
}

<Person>
  <name></name>
  <name></name>
  <Age></Age>
</Person>

the above works. The following "works" but it's null.
<Person>
  <name></name>
  <Age></Age>
  <name></name>
</Person>
 
Which XML serializer?
 
Default
It shouldn't care about <name> being separated like that
 
Hm. Not sure. I wouldn't expect the latter to produce meaningful output anyway. I've been thoroughly abused an institutionalised by DataContractSerializer
Which hates everything
 
 public static T DeserializeFromXML<T>(string xml)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(T));

            using (System.IO.TextReader r = new System.IO.StringReader(xml))
            {
                T value = (T)serializer.Deserialize(r);
                return value;
            }

        }
 
Impedance mismatch. There is no particular way that XML serialization should work, they're different paradigms. In other words, I don't think there's a right answer
Give it what it wants and move on with your life, or implement custom serialization/deserialization
DataContractSerializer would barf on either of your examples, I think
 
5:50 PM
i can't, clients send us XML. it could be out of order ;p
the sample I posted was an example, they're sending us a complete HL7 snapshot of a person (500 lines)
 
is this BizTalk or post-BizTalk?
oh, stupid question, you wouldn't be writing serialization code
1) HL7's schema is poo if it permits that 2) I'd be looking at a caching and rearranging XmlReader to reassemble the message in a sensible format
 
Post biztalk - just C#
We auto-generate C# proxy code based off of the HL7 schema
then map to our object
I could use a TextReader/Writer for it, but that's just too much work :P
there's no reason this "shouldn't" work
 
well, I've just been doing some reading, apparently XmlSerializer doesn't mind order of elements, but presumably arrays of elements are a special case
if they just mapped to properties it'd probably be fine
Hm. How are you generating those?
 
HL7 is a standard of some sort?
 
Yea it's a standard.
HL7v2 is a |/@^~ delimted file
 
5:59 PM
svcutil assumes DataContractSerializer IIRC, which is very anal about the schema it expects conformance with
 
HL7v3 is XML
Yea, i changed that to be XMLserializer
 
oh I see, didn't realise that was an option
 
So when the <name> elements are scattered within the parent element it does not deserialize any of the <name> elements?
 
@scheien It deserializes them until it comes to the one that's not in the same sequence. Once it comes to that, it doesn't deserialize anything else.
 
yeah, that's not good
 
6:04 PM
I'm leaning toward 'not supported'
 
IT should be, worked before on other projects
It even works with a different set of objects
previous Schema objecvts, just not new ones.
 
Including ones you'd expect to deserialize to an array?
 
Yup
I think i know what it is
[System.Xml.Serialization.XmlElementAttribute("addr", Order = 1)]
i think it's expecting them to be in a specific order - autogen code #%$@#
 
My linqpad does not deserialize any of the name elements when I use the code you posted.
 
well my XML wasn't properly typed
 
6:11 PM
aha, thought that was a sample
 
There we go
as soon as I took order out it worked
autogen crap
 
hehe
yea, you can't trust the autogen stuff, it will bite your hand off
 
THere you have it. Using Order with an XML Serializer is just asking for errors
Sad thing, it looks like you sometimes really need it with DataContractSerializer
youtube.com/watch?v=HuTcsGHfc1g - great soundtrack to code to
 
 
1 hour later…
7:34 PM
hello .. can someone help me out here on web api 2 and EF 6 . I have a Users(getAll) api and there are 100 users my table.Every user is different and belongs to different companies.
Asumming that company A is request for his users - how should I filter this based on companyID .. whats the best practice here.Should I password CompanyID in request header?
 
8:07 PM
@RyanTernier had a really shitty one with DataContractSerializer
Was generating a soap message for a WCF service using XSLT. The input document might need the output elements reordering. Unfortunately, the natural order that DataContractSerializer creates for its schema is no notion of alphabetical ordering used by anybody else anywhere
 
8:22 PM
@TomW Sounds like fun:)
Thing i'm fighting now is :

1) Client expects that all messages that get sent to them come in a specific order
2) client does not care about what order that same message is in when it gets sent to us
<3 clients :)
 
8:49 PM
In what order?
 
No order :) They are just hypocrites ;)
 
People who don't possess the intelligence to i) recognise what their requirements are ii) communicate them coherently iii) comprehend when they're shown that they make no sense, are not at all uncommon it seems
 
9:20 PM
o/
 

« first day (1682 days earlier)      last day (3249 days later) »