« first day (166 days earlier)      last day (4790 days later) » 

8:05 AM
Hi Guy's
I could do with some help if anyone is around?
 
Ask away. Sometimes it takes a couple of hours to get an answer, though.
(It's actually sometimes faster to post a question to the... well, Q&A site itself.)
 
But every so often someone is lurking in here
even better is to try the meta chat if you rep on MSO
 
8:21 AM
Thanks, with that in mind i added to the wall which is essentially my question(s) stackoverflow.com/questions/5496972/…
 
 
3 hours later…
11:09 AM
any one here to help ?
 
 
2 hours later…
1:29 PM
@drachenstern . What do you mean by "if you rep on MSO"?
 
@Parkhid sure... ask away
 
2:09 PM
@Parkhid i'm around, too.
@suokotto you ever figure out that deploy question?
 
Several people answered that I have to install .NET 3.5 on that machine. I'll try that later today
 
yeah, that's what I was just going to say
 
Sucks if that's true...
 
I'm pretty sure that's the issue
as Linq is included as part of that install
 
since I have no control over what other things the user(s) will ahve on their machines
 
2:12 PM
you can create an installer that will require .Net 3.5
and install it if it's not found
but that's obviously a pain to create and use, rather than just xcopy
 
I was hoping I could compile everthing needed into a single binary (or binary + support files)
 
I personally don't think it's too much to ask for them to have the proper version of the framework installed
 
That was a reason to move away from Java back in the day
 
2:28 PM
i suggested using nsis on your question
or some kind of installer
that will require them to do the install
most newer versions of windows have .net installed already, too.
is this just a corporate app?
 
yes
 
2:46 PM
@Sukotto I seem to have left off the 've from my post ... "if you've rep on MSO"
 
 
2 hours later…
4:31 PM
i have a multithreaded application
 
Congratulations
 
i need to know what kind of discipline i have to follow when i m using a thread to handle some stuff
that is
rught now
i am just using it to listen some port and add the objects of clients that connect to me
other than that i havent done anything to it
@drachentster: lol,
so as i was saying i have one thread that keeps listening on a port
and adds the client objects to an hashtable
so what is the correct way to terminate the thread and all other objects that ive added when the thread was active
??
 
So for starters, you can take your time and write your question as one post, so around up to 500 characters.
 
oops sorry
 
Number two, have you had any formal education on this? There are some uni classes that spend two months of lecture on this very topic. There's all sorts of things to be considered such as mutexes and whatnots, depending on what you are trying to accomplish.
 
4:36 PM
no as far as multi threading is concerned this is my very first app, i can see that they way i have handled my thread now is very awkward and clumsy
 
So what have you read on multithreaded apps?
 
just the normal thread life cycle, and stuff. thread.start and suspend and very basic stuff really, never heard of mutex before, googling it now
 
In computer science, a thread of execution is the smallest unit of processing that can be scheduled by an operating system. It generally results from a fork of a computer program into two or more concurrently running tasks. The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process. Multiple threads can exist within the same process and share resources such as memory, while different processes do not share these resources. In particular, the threads of a process share the latter's instructions (its...
I definitely recommend you start there
 
well thanks for offending me by pasting a wiki, which clearly shows u havent understood my question anyway
i asked abt best practices to handle a thread and mr.knowall is totally misinformed
 
No, you don't understand what you don't understand
Until you understand that there are at least four major ways of multithreading and can identify what the major pitfalls are for the one you're using, I can't really give you specific advice
10 mins ago, by swordfish
i need to know what kind of discipline i have to follow when i m using a thread to handle some stuff
Until I know what you're doing with your threading, I don't know what the best discipline to suggest is.
 
4:43 PM
@swordfish I don't think he was trying to insult... that's a useful article, even for an experienced progrmmer
 
well u could have asked for a bit more explanation like this at first, isntad of insulting me with a wiki paste
 
You should know that there's going to be problems with memory spaces that multiple elements need to address, that you have to manage order of accessing, you should understand the dining philosphers problem
@swordfish never saw it as an insult, you have my sincerest apologies there. I always recommend an educate first approach instead of a "let me make my code work and then put duck tape on the stuff that doesn't work" approach.
When you have a system where one thread listens on a port and puts something into shared memory, and other things read that memory, you need to know who's reading and who's writing. That requires locks. Or mutexes. You also probably shouldn't be removing the listener until you exit, unless you plan on re-establishing it often. What's the use-case there? Can you give me the business-logic of why you want to remove it before you exit?
 
Ok im sorry too if i was being a little watever. My app is kind of a tcp server with a gui. There is a frontend with some, a lot of textbox which the user fills and click on send. this info must be sent to all the clients connected with the server. As of now when the app initilizes i start a thread to listen for clients. For each client connecting there is a new instance created by the thread which i then put on a hashtable, so that i can go over them and send the data later.
 
"a tcp server with a gui" makes me kinda nervous. Those two things don't go together. I don't butter my cat.
2
 
This thread which listens for clients is just doing the stuff and i am not caring about it until the app exits. this is where i am worried
well its not exactly a tcp server its kind of.
 
4:49 PM
@drachenstern hahahahaha
 
Ok, let's try this again ...
 
@drachenstern lol great metaphor
 
What exactly are the requirements of this app? It sounds so far like a client-server with a in-session database instead of something disk persistent.
 
its kind of that. let me explain
 
Please do.
 
4:53 PM
there is an application called agent with its own scope. The agent will listen on whatever port we say and recieve the data and do something with the data. Its none of our business. All we have to care is that we should tell the agent a port to listen to and send data to that port so that it can do its stuff.
So what i did is create a tcp server like app which can open a port and send data to it, only the data is given by the user from the GUI. So now our app is like a tcp server and agent is like a tcp client. I cannot modify anypart of agent, so i have to build my app in accordance with it.
 
And then the Agent sends data back to you?
 
yep
but it doesnt send ling strings
it just sends one notification that it had recieved the data
i know wat ure thinking, its kinda confusing to consider the agent as a client, but doing a server job
 
no, that's not confusing
 
thn im glad its not, cuz i was so confused at first
 
I'm curious why you're putting a gui on the "server" app. It sounds like you would want an automated style where you can have one or more operators sending data from a "client" into the "server" which can then send data out to one or more "agents" ... the concept of putting a gui on the thing doing coordination makes me nervous, because those gui apps get the X clicked a lot
So the main thing you want to be worried about is the memory locking problem
You can't read and write from the same location at the same time.
a simpler name for the concept is a handshake
 
5:01 PM
no forget abt the notification tht the agent sends
we dont have to care abt it really
 
I imagine you're going to need to keep two dictionaries, one for "data" and one for "I need this resource" if you want to do item-level but I would just keep a global flag instead of trying to make it complicated
if you dispose of the data that the agent sends you still have a read-write problem
 
how is that
 
well, I suppose not if you keep killing the communicating outbound thread and re-establishing it
do you know how a distributor cap works?
 
sorry no, and no i cant kill the connection and reestablish it each time
 
ok, so you maintain one connection per thread.
 
5:04 PM
the connection once started has to be persistent until the agent disconnects
 
Yeah, I grok that
just wanted to make sure
so each of those threads has to read from the common in-memory dictionary, yes?
 
yes
 
So when they read from they will be conflicting with the "server" that is writing to the dictionary
so you have to manage those states
mutexes
ok, pardon me, /afk
 
hahh i got it now
thanks reading up on mutexes now from msdn, looks like this might be it
 
@drachenstern mutexes? or Monitor..., lock(x) {}, semaphores
 
5:13 PM
sorry
@DavidKemp semaphores and locks are forms of mutexes
dining philosopher is the common deadlock/spinlock to avoid
 
5:57 PM
i was musing thoughts over url/route schemes what type of schemes would work for basically a dictionary? I'm struggling to come up with better routes than /Query/?name=bob&zip=90201&gender=m&page=5&size=100
Some of my first thoughts were along the lines of using the pairs in the url like: /Query/name:bob
at that point however my thoughts start to break down since i'd need to consider either /Query/name:bob/zip:90210/ or add in some kind of separator and have like /Query/name:bob&zip:90210&gender:M/?page=5&size=100
Has anyone ever seen (or made) a really good search terms url along this lines?
 
lzm
i'd rather use the standard /Query/?name=bob&zip=90201&etc=etc than some made up scheme
 
that is definitely the easiest option, it just always feels gross, and that the more &'s join stuff together the less human hackable it becomes (or atleast feels to me anyway)
 
I am hearing that java is loosing it's popularity.How far has c# affected java
 
6:21 PM
@suh
er
 
@ChrisMarisic what ?
 
lzm
6:55 PM
WCF is such a pita
 
7:39 PM
@lzm Indeed
 
lzm
7:55 PM
i blame its short levenshtein distance to WTF
 
hi
 
lzm
hi
 
8:18 PM
Hi do any body used the monotouch framework to create Iphone App?
 
@khaldoun, I have not, but it looks interesting
 
8:42 PM
It is a very nice plateform however , tuto and ressources are limited
and it is not free you have to pay a licence to get the id to develop iphone app using c#
 
@ChrisMarisic how many different search terms will there be?
 
@Nick between 3 and 6, if my search has over 6 terms at that point i wouldn't care about url quality since it will have so many terms that it will override the whole url outside of the terms to start with
 
@ChrisMarisic You could set up your routing in such a way that you don't expose the key, just the value. mywebsite.com/m/bob/90210/stuff
and if the user doesn't specify one of those have a default value place holder.
 
8:59 PM
when i said dictionary i said that in regards to basically that's the data i need input, basically pairs of column names and string values to search for
but the number of terms isn't a fixed value since they could search against 1 or a bunch of different columns
 
I understand that, so if the first two spots are for name and zipcode and the third is for gender, and the user only searches for gender then you would have default values for name and zipcode, like this: mywebsite.com/search/default/default/m
where "default" could be any value
I think query strings, no matter how they are formed just look ugly :/
 
well you just gave me a similar idea
to create a hybrid route key pair like
/query/name:bob/zipcode:17111/
and allow /query/name/zipcode:17111/ or perhaps name:/
probably would be very easy to add a route value binder or w/e it's called that would be the last one called to check for : in route terms and split them if found
 
9:18 PM
key:value looks a lot nicer than key=value imo
So I would go that route like you we're thinking
 
and that will work well with paging since those can just end up as regular querystring terms after the url and i get to keep all my nice auto paging
 
Funny little C#/VB thing here.
private bool? _uMadBro; in VB is Private _uMadBro As Boolean?
Reddit readers will appreciate
 
yeah i've never been a reddit user was always a digger so i think the meme is lost on me
 
@JeremyChild what does the ? mean.
 
nullable
 
9:23 PM
as in optional?
 
not a C#er i take it?
in C# primitive types aren't capable of not holding value
 
sometimes you have to work in both worlds
:(
 
I am, but have never needed to use nullable
 
in the release of .NET 2.0 they created the Nullable<T> type that allows you to create nullable primitive types so you can differientiate between set vs not set
 
@ChrisMarisic This is something that most .net developers don't understand; having given lots of interviews
 
9:25 PM
;/
 
bool? is just a shorthand for Nullable<bool>
nullable types are completely awesome
 
i have almost zero usages of int / long / decimal / bool in my application
i nearly solely use nullable types
 
When you have to use a database you didnt design you have no choice
 
int y = x ?? -1; very cool
 
9:27 PM
the null coalescing operator is also one of my favorites
 
I like the ternary operator
 
you can never end up with statements as clean with that one
 
Didn't it come out in 3.0?
 
Looks that way
 
i think ternary was always there and that null coalescing was 2.0
 
9:28 PM
@ChrisMarisic Sometimes I will make a line break after the "?" in the operator
 
yep you can get decently stacked code with it
some interesting code with .NET that i use occassionally
 
Can someone explain the yield usage to me
 
PropX { get { return _x ?? (_x = DefaultValue); } set { _x = value }
 
Chris can you explain what you meant by "in C# primitive types aren't capable of not holding value"? To me null is a value.
 
i agree fully Jeremy null is completely a value
 
9:31 PM
Which is what some people don't fathom?
 
primitive types, int, bool, long are not capable of being null
you cannot do int x = null
you however can do int? x = null
@Nick the yield operator is one of the more interesting points of C#
 
to me nullable is just a container for either null or a value of the original type. Thats my understanding. Only been doing this for a year or so.
 
when you use the yield keyword it's always in combination with either yield return or yield break
 
So you think your primative type is null, when it is the nullable object that is null.
 
that is a pretty good way to look at it, however that's actually glossing over some core .NET stuff about nullables
nullables themselves are actually structs
you can't have a null struct at all
somewhere a little magic happens that the CLR knows you want to interact with the values correctly, and the struct tracks whether the primitive type has a value or not
so even when you do int? x = null; you truly don't have a real null value in the sense of if you do SomeClass x = null
moving back to the yield statements
yield is used conjuction with IEnumerable
so an example would be something like this
public IEnumerable<int> GetFirst100Numbers()
{
for(int i = 0; i< 100; i++) yield return i
}
 
9:39 PM
@ChrisMarisic sooo what would be the outcome if you just used return i
 
so if you do var myNums = GetFirst100Numbers()
if all you do is that assignment, at this point var myNums is empty
if had you the method coded with return i instead of yield return i
 
If you're running a for loop I would assume that you will get the value of i 100 times if you just use return, and each time it will be incremented
 
calling var myNums = GetFirst100Numbers(); at this immediate second you now have memory allocated for basically an array of all the numbers for 0 - 100
 
I'm firing up VS to test this baby out
 
you're thinking about it right nick
with an IEnumerable you'll usually traverse it by doing something like
foreach(int num in myNums) Console.WriteLine(num);
so if you would use that example where you walk that list of 100 numbers
if you use return i; you will place all 100 i's into memory
if you use yield return i
you will place only a single i in memory
so with VS open if you code all this up
with yield return in the method, if you set a break point in the for loop
 
9:44 PM
Ok, but when you say single do you mean a single array with 100 i's in it
 
no
1 single value
as your foreach statement executes as interator
you will execute the code inside of the GetFirst100numbers
so as your foreach walks, it will causing the for i loop to increment
you really need to try this out to really grasp it
create that method, and set a break point at yield return i;
and a break point in the foreach loop
 
Ok, I am now
 
with the IEnumerable the method never needs to return more than 1 current value
because with an IEnumerable all you have is Current and MoveNext()
it allows you to write some very interesting code that you can work on gigantic data sets without needing huge amounts of memory
there's a project based on that idea called Rhino ETL (extract transform load) that all of the interfaces drive of IEnumerables so you can code up massive data imports/transformations and run them without loading full files into memory ever
yield return naturally fits with optimizing access to discrete resources
take a csv file for instance, if you need to pump all that data into a database
you could choose to the read the entire file at once (there's even nice methods to do it like File.ReadFile("some.csv")
which then copies all of the data into your memory directly as a string
thats not a probably if a csv has 100 rows, or even 100,000 rows but think of 100,000,000 rows
thats not a problem*
with the yield return
you would do like FileReadLine( while(Reader.CanRead()) yield return Reader.ReadLine() }
and then you can enumerate across the entire 100,000,000 row csv file 1 row at a time without wasting tons of memory to grab it all at once
it's a really useful concept to know, it's not one that you'll need to implement very often, places that can use it best usuually are in frameworks that people have already written
 
What about plinq?
 
like my example with reading a file is exactly built into .NET because reading full files in 1 shot is costly
plinq as in parallel linq was features added to .NET in 4.0 that allow you to take a collection and have the method like var mylist = new List<bob>(); mylist.AsParallel()
var parallelList = myList.AsParallel()
foreach(var item in parallelList) Console.WriteLine(item)
 
9:58 PM
Yes Ive been using asparallel quite allot
 
executing that foreach will automatically cause it to become concurrent threaded programming without hassle
 
and we can all do without hassle. right?
 
if you do thick client or WPF it would probably be used alot
indeed
i wish threading was as trivial in ASP.NET as thick client now
 
we're actually using it on our data layer in an asp.net website
 
be really careful about that
when you use as parallel you're causing that to spin up threads for the parallelization
IIS only has a finite number of threads to allocate
 
10:00 PM
yes indeed
 
if it's out of worker threads, people on your site will wait until threads become available
 
the app pool has set amount of threads
interesting. thanks for your insight.
 
i think what .NET needs to do to solve that problem
is that a worker thread should be able to spawn child threads that are part of that overall worker
so that parallelization would be very more trivial for asp.net
or perhaps that they would create a 2nd seperate thread pool just for non worker threads, and let AsParallelized stuff just check out threads if they're available otherwise to fall bakc to single threaded
 
without congesting the site visits
 
exactly, seperate from the core worker thread required to serve html for visitors
threads
and of course as easy as it is for me to say this, i know the implementation of this would not include the use of the word trivial anywhere close to it
 
10:03 PM
possible to send threads off to work outside the iis/app pool stack?
 
not readily
generally people that wish to go down that route
will either use WCF or direct windows services
or a combination, WCF service hosted as a windows service
 
Yes indeed. People that are writing such intensive apps need to look at their architecture rather than hacking away at asp.net
And or think about caching and database performance etc
 
exactly, generally that level of complexity isn't needed for most CRUD apps
now if you were creating a website that did video transcoding for people
 
I recently started working for a small company that has a system called Kronos.
And Kronos treats the database like a dog sometimes. Locking tables without warning and such.
 
!
 
10:07 PM
So they way they've accidently engineered it means the locked tables causes a backlog of sql queries as those tables are used in every second view.
facepalm
 
i googled and found kronos.com
 
Are you talking about Kronos that makes time tracking software?
 
Yes indeed
 
looking at the site it just screamed Lotus notes
"build you're business around us, come on you can trust us"
your
 
10:08 PM
If they contact me I'll send them here
 
Well its a great system
Used by Fortune 500 companies etc
Just useless when it starts doing its cleanup/cron work.
"Hey evvrybody we're going to just lock these critical tables until we're done excreting over them.kthnxbai"
 
haha
 
i'm heading out guys it was good talking to you, if you want to find me at some point contact info is all on my blog www.marisic.net
i really need to get around to blogging more =/
 
by
 
Anyone had any experience caching the EF?
 
 
1 hour later…
11:18 PM
Looking for posts to upvote so I can see a unicorn!
 
Hi guys
 
11:51 PM
whooot. gotta catch them all Unicorns!
 

« first day (166 days earlier)      last day (4790 days later) »