« first day (965 days earlier)      last day (4205 days later) » 

Is it ok to do this public class Connection : Form1 ?
@Loclip What?
Ewww
Why would you call a Form a Connection?
I want to call a Form1 function from the class
That's not how you do it.
If you want to call a function from outside a class, make it public.
14:13
my function is public
You need an instance of the Form to call it on.
You can't just call a function on thin air.
so make Form1 frm = new Form1()?
NOOOO
What function are you trying to call?
@drch how do you check the connection state?
I'm assuming you have only one Form1 ever open, right?
14:16
its just one function that disable textbox and change button text
yes
The way you probably should be doing it is making an event in Connection, and subscribing to it in Form1.
@drch because I already have this:

if (((ICommunicationObject)channel).State == CommunicationState.Opened)
                        {
                            m_subscribers[channel].AddLogRecord(r, false);
                        }
                        else
Rather than making the connection in charge of updating the form
@KendallFrey hmm I never tried something like that.. can you give me one example from internet?
14:18
what is the difference between Microsoft Jet 4.0 OLE DB vs Microsoft.ACE.OLEDB.12.0 ? I mean if they both are for office connectivity then what is the difference ?
anyone ever tried remote debugging ?
visual studio 2010
The Microsoft Jet Database Engine is a database engine on which several Microsoft products have been built. A database engine is the underlying component of a database, a collection of information stored on a computer in a systematic way. The first version of Jet was developed in 1992, consisting of three modules which could be used to manipulate a database. JET stands for Joint Engine Technology, sometimes being referred to as Microsoft JET Engine or simply Jet. Microsoft Access and Visual Basic use or have used Jet as their underlying database engine. It has since been superseded for ge...
In the "History" section, it shows that ACE is just the newer version of the JET database engine.
@Alex i assumed that the reason that the service got funky was because that thread was still working after a client abort
@ShotgunNinja Thanks for the answer, now as my system is WS 2008 r2 I believe I need 12.0 version
14:26
@drch - Yes, I think this is why as well.
@drch - But I check the state, and yet still, it messes up, unless I have to check the state in some other way...
how long does it take for that loop of results to iterate through
my version checked after each message was sent
yours checked once up front
@Zerotoinfinite Hope that helps.
it can take a really long time depending on how many results there are
thats why the more results there are the longer another client has to wait until it goes through
although - it might be moot cause youd probably expect an exception if the service tries to write on a closing/faulted channel
but no @drch it checks it for each loop
14:29
oh hang on - this blocks OTHER clients that are already connected?
foreach (LogRecord r in results)
                    {
                        if (((ICommunicationObject)channel).State == CommunicationState.Opened)
                        {
                            m_subscribers[channel].AddLogRecord(r, false);
                        }
                        else
yes, it appears to block!!!
sorry
I MEAN... it ONLY blocks when the callback channel faults out on the server side!!!
like when
the client user manually terminates its client application process thats connected to the server and that worker thread on the service side cant make contact to the the client
then it blocks other clients connected to it!
ok just looking at this code again
any time a client calls 'query logs' it broadcasts to all subscribers?
@drch - okay :P me too lol, its driving me nuts!
no, it only broadcasts to the client that calls it
so why do we need all this threading and dictionaries
what do you mean?
more specifically, which threads and dictionaries?
Thread t is a worker thread that sends log messages to the client after it connects to the service
14:38
right but whats the harm in doing this all synchronously
why spin up a new thread per method call
querythreads holds the worker threads that need to be terminated on an unsubscribe, but i also need to figure out how to terminate these threads when a callback channel is deemed no longer usable
oh you cant do this synchronously
theres just way too much data to send to the client
thats why all the methods on this service are oneway
no i mean this particular method
once you subscribe, it sends you messages
you are spinning up a thread to put the message on a worker thread
oh no, its just one thread per client
see it checks if the client is part of the list or not
one worker thread max per client
14:41
so a client connects (subscribes), calls querylogs, and then unsubscribes and disconnectS?
if(m_subscribers.ContainsKey(channel) == true && !queryThreads.ContainsKey(channel))
{ // create a worker thread for this client since it doesnt already exist
using the callback channel as a unique client identifier
yeah
but sometimes
the client doesnt unsubscribe
because the client application process might terminate
i cant guarantee that clients will call the unsubscribe method
do you need to keep track of this thread like this?
thats the problem really
I'm trying to new Thread(new ParameterizedThreadStart(myStaticVoidThingy));
But I'm getting an error
since its only really referenced here right?
14:43
yeah, i do, so that i can then abort it
No overload for 'myStaticVoidThingy' matches delegate 'System.Threading.ParameterizedThreadStart'
But I'm following @drch example, but it is not working ;-;
if i figure out a way to check that the callback channel is no longer good, but i cant seem to find a way to check that properly :(
but you dont abort it anywhere outside of this method right?
right
so you dont really need to abort it, you can just return out of it
i dont know what the hell happens when you abort a thread from the current executing thread but it sounds bad.
14:46
AHH
thats probably it
ill try this, LOL:
foreach (LogRecord r in results)
                    {
                        if (((ICommunicationObject)channel).State == CommunicationState.Opened)
                        {
                            m_subscribers[channel].AddLogRecord(r, false);
                        }
                        else
                        {
                            new Thread(() =>
                            {
                                SubscriberBuffer buffer;
                                while (queryThreads.ContainsKey(channel))
new abort thread ;)
you dont need that while() noise either
tryremove should only return false if the object wasn't in there
i just wanna make sure theres no duplicates, but youre right itll likely work without
hmm
even though i changed to a new thread
it still has the same behavior/issue
damn it...
its this
if (((ICommunicationObject)channel).State == CommunicationState.Opened)
its not a good check... its not enough to see if its a bad channel
ill brb in a bit, ill check your messages when i get back
hi all
any one help me to get selected item object from listbox in wpf ?
14:56
@Alexandru yeah it seems like it will take a while for a disconnected client to bubble up to the server. so if your goal is to abort early, you could have the client method return a value and then call it (and abort if you dont get a response with a timeout)
if the goal is just to allow a client to reconnect and work, and let the other thread abort whenever it does eventually figure out whats going on, then use a different key than channel.
no one can help ?
@Splinky, myListBox.SelectedItem
@catbert i need my object in the selecteditem
@catbert SelectedItem="{Binding SelectedPc}"
private pc _SelectedPc;

public pc SelectedPc
{
get
{
return _SelectedPc;
}
set
{
_SelectedPc = value;
}
}
how to acess the selected pc when i click ?
oh so you want to bind to a property?
yes
i want to get my object pc that have image and labels and ID and ....
15:05
you probably want to read this: stackoverflow.com/questions/2012460/…
I'd do this without bindings.. when you click the button, just check the SelectedItem property
var selectedPc = (pc)myListBox.SelectedItem;
i have readed it but i need the event of click to get my pc
ObservableCollection<Pendencias> message = (ObservableCollection<Pendencias>)
                                    (new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter().Deserialize(stream));
For some reason this line gets stuck
Anyone already used BinaryFormatter ?
I can't understand you :-( do you want to do this on click?
@catbert i need the event of clicking?
@Andre: can you just serialize the elements?
15:08
myButton.Click += (s, ea) => { var selectedItem = (pc)myList.SelectedItem; ... // do something with selectedItem };
i don't need a button i want to click in listbox item
pc p=(pc)liste_pc.SelectedItems;
Console.WriteLine(p.lab); get System.InvalidCastException
:p it is working with pc p=(pc)liste_pc.SelectedItem; without 's'
@catbert thx a lot my friend :)
@Splinky np :-)
@catbert one question if u want
Hey everyone.
it is working just when i change selection
hi
@catbert private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
pc p=(pc)liste_pc.SelectedItem;
Console.WriteLine(p.lab);
}
15:13
What are you trying to do?
this is working just when the selection is changed
i need to get some thing but when click in item
not in changing
@Splinky So I understand, your trying to write an object out once the item is selected in the ListBox?
yess
What you may want to do, is when a MouseEvent occurs- Grab the index of that item, then read out the Indexed item.
2
Q: Handling double click events on ListBox items in C#

Hans EspenI am trying to do something when double clicking an item in a ListBox. I have found this code for doing that void listBox1_MouseDoubleClick(object sender, MouseEventArgs e) { int index = this.listBox1.IndexFromPoint(e.Location); if (index != System.Windows.Forms.ListBox.NoMa...

An example.
Brb, meeting.
i want to get the object binding after click
15:27
@LewsTherin nice man, have been at the beach all day. Going to the horses now, back in an hour or so.
Kwl.. I will be here
Am I still a room owner?
nope :\
Whatya need Hans?
last summer I was on here a lot
so the powers that be made me a room owner
but then I stopped coming here because my internship was over
life got in the way, etc
15:30
If you hang out here more, you'll become an owner again.
I'm still an owner, somehow...
If you don't want to be I can certainly help.
nah, moved on to less greener pastures
my current job uses java and php
@HansZ bleh, Java AND PHP?
Where do you work?
a web company
very popular one, too
15:43
Google? :P
any more hints?
location, catchphrase, etc.
name...
what's your favorite store to shop at?
google that store's name + coupon
try any store
(almost any store)
hmmm groupon?
That's the first name that comes to mind.
Groupon or Amazon?
retailmenot?
Target
Now that you've made us guess for so long, I'm not as impressed as if you just told me.
yeah retailmenot
it's also on my profile page
it wasn't supposed to be a guessing game :\
Cool accomplishment.
15:53
It is already marked
I've noticed a trend at my office of poorly written XML Documents, really makes parsing data a pain in the ass.
Anyone read that new book on Async or EF 5?
guys, quick question. I have a logout control (which redirects to a logout page) on an MVC master page. When I click said logout button, the controller seems to override the logout click and just re-displays the page. Any ideas?
@StuartBlackler Can you post your code for the controller.
@Greg unfortunately not, company restrictions (I know it would help massively). I can confirm the definitions of the functions in the controller at a push maybe
@Greg Lately yeah.
> the controller seems to override the logout click
??
@LewsTherin Based on what he said that was my thought.
On the Event it either pulls the wrong view or model.
16:04
@LewsTherin by that I mean that the page effectively refreshs
If you are redirecting, shouldn't it?
yea it should...
But it doesn't redirect to the target page
It should refresh, but then it should automatically redirect outside of the authenticated zone.
on the control i set the logout action to redirect, the url to ~/logout.aspx and the text to Log Out.
16:05
And your positive it is pulling a valid URI for that page?
@Stuart is it a <button> ?
So it essentially knows to logout, then go to the directed page.
when you click logout, what ever action the controller last did (eg details) is the event that gets fired again
so i load: /Controller/Details
click logout
and it hits my breakpoint on /Controller/Details
inside of that it has: return View("view name")
this is mvc right? whats the markup look like for the logout? is it an <a>? a <button> an <input?
it renders as an <a> with a javascript postback handler
16:09
postback... that dont sound like no mvc ive ever heard of
<a id="2_loginStatus" href="javascript:__doPostBack('2$loginStatus$ctl00','')">
as per IE dev tools
you are using webform controls in a view
they dont play together like that
because you dont have viewstate, there's not event handler to get fired and whatnot
yea i know, im just trying to bugfix...
i can change it to be the MVC way, but I dont know what that is
you just cant mix and match like that
i just got put on the project to fix this one bit and it was already like this... :/
so how do i logout in the MVC style
16:12
<a href="/mycontroller/logout">
so i have to do that on every controller or can I do that from the master page?
im having a tough time even figuring out how that page gets rendered
is there a master template in /Views/Shared ? maybe theyve just put the wrong master in the view
@drch Wouldn't it be better to use razor <a href="@Url.Content("")" />
@Greg yes, or @Html.ActionLink()
That way it grabs the proper URI
16:14
so I could use the @Html.ActionLink to point to Auth/Logout from the master page?
the master page isnt where it should be, but its there...
possibly...
guess there is one way to find out... 2 mins
hopefully its just a matter of someone accidentally putting an <asp:HyperLink> in an mvc aspx view.
How would I use WebClient to use google or yahoo search engine?
If your lucky-
16:16
Is it WebClient or HttpWebRequest?
I'm a relatively new developer and I see really bad development practice constantly.
@drch youll be lucky ;)
webclient is a simpler api
<%: Html.ActionLink("Log Out", "Logout", "Account") %> that worked.... Thanks guys I owe you one, big style. + rep coming your way later tonight :)
yay
16:18
I could do pass this string to WebClient: "https://www.google.ie/search?q=lol&oq=lol&aqs=chrome.0.57j60j59l2j61l2.543j0&so‌​urceid=chrome&ie=UTF-8"
But that sucks
Looks like they changed their url lately
Glad it helped you.
Yahoo's url is even worse.
google has a search api but its limited to 100 / day
bing is 500 /mo with some rate limiting
I will stick with bing and google, and append the search query to the url ;) It's just an experiment after all
@drch Wouldn't be harder to send it all at once ?
16:28
?
You sent me a reply
About serializing each element instead of the whole collection
well if you made an array of the elements and serialized that instead of an ObservableCollection
also to use binaryformatter, you have to make sure that all your classes in the object and its members are [Serializable]
er, member types i mean
 [Serializable]
    class Pendencias
    {
        public int proCodigo { get; set; }
        public string proDescricao { get; set; }
        public int solCodigo { get; set; }
        public DateTime solDataSolicitacao { get; set; }

        public override bool Equals(object obj)
        {
            var newObj = obj as Pendencias;

            if (newObj == null)
                return false;

            return this.proCodigo.Equals(newObj.proCodigo);
        }


        public override int GetHashCode()
16:32
yeah that seems fine
Out of curiosity.. why are you overriding hashcode to be that of proCodigo?
Both sides are like that
Doesn't hashcode identify an object?
@LewsTherin Can I be honest with you ?
no, because theres only int.maxvalue possible hash codes ;)
16:33
@AndréSilva Yeah
@LewsTherin I have no idea why I did that override, someone here told me to do it and I did it.
if a.Equals(b), then a.GetHashCode() must equal b.GetHashCode();
@AndréSilva :L
@drch Yeah
So the hashcode identifies an object instance
@drch - So I figured it out! My colleague coded up a different thread function that would call the callback channel, and it was looping through all the channel subscriptions sequentially, so I had to add fault handling logic and shit. LOL what a nub
and threading to parallelize it
ugh, i didnt realize this til just now
i had a revelation while i was eating mcdonalds LMAO
but thanks for pointing out the faulty kill thread :)
> What a nub :L
16:41
So, @drch how would you suggest me serializing ? Using an array ? Ok. But with what serializer ?
you could use binaryformatter if you like
and actually i think your observable collection should work as its marked serializable - just not sure about the event handlers.
whats the error?
No error.
When it steps inside the deserializer
It freezes
Even though I can see that it retrieved the information from the server
so just do myobservableList.ToArray() and serialize that and see what happens
Ok, one second
Still froze
Is it possible that it is taking so long to deserialize 5k information ?
maybe but those objects look pretty light.
16:53
Yep
The highest length of a byte that I can get is about 6k
byte[6048] is the highest
try with myList.Take(1).ToArray()
Still takes more than 3 seconds :X
Even if it works after that, it isn't viable
try json
I've never JSON'd c# to c# o.o
Try Newtonsoft.JSON
16:58
how long is that string in the object?
Nothing big.
ill test locally as well. binaryformatter isn't the greatest but it hsouldnt be quite that slow
5 fields, the sum of them won't pass 30 characters
I don't think it is slow
I think I'm doing something wrong.
TcpClient client = new TcpClient();
                client.Connect(new IPEndPoint(ipAddress, Port));

                NetworkStream stream = client.GetStream();

                byte[] bLength = new byte[4];
                stream.Read(bLength, 0, 4);

                int length = BitConverter.ToInt32(bLength, 0);

                if (length > 0)
                {
                    byte[] data = new byte[length];
                    stream.Read(data, 0, length);
                    ObservableCollection<Pendencias> message = (ObservableCollection<Pendencias>)
My data variable works like a charm, it has the same content as the server side
But BinaryFormatter accept only a stream so I'm sending the stream that I'm using to read that.
Great the wifi stopped working
431 ms to serialize 50000 objects
in my test on this shitty computer
So I'm doing something wrong for sure
17:06
OH well sure, serializing AND sending is going to be as slow as the network
I can't test it right now.
Wifi stopped working.
Is stream still getting data from the network?
Or is it just a temporary object?
@AndréSilva How are you connected to the network? :O
Temporary object I believe
This computer by cable and the server on wireless
17:09
If you have access to the server, you could run it on your PC
39 ms to serialize 5000 objects
data size {0} bytes 5305329
46 ms to deserialize 5000 objects
Can't see pastebin.
Put on gist
Please. :)
Fastest serializer is still nuget.org/packages/protobuf-net isn't it?
May be food for thought
good point, altho his bottleneck will be network.
17:12
In testing mode yes
I want full native stuff
The idea is to have a robust server with a dust-size client
For fucking sake the wifi went down. I'm going to grab cigarette
Be right back
what is it with London and letting your dog shit on the sidewalk
I blame foreign people
17:29
damn foreigners
Aaand I'm back
What is the possibility of the companys wifi blocked my access right now ?
Since we can see your messages, about zero?
This computer is on cable
Random question- Might be borderline stupid.
I have a large amount of variables that are used globally throughout an API, to avoid potential Security Issues I created two class, the baseclass is protected but then I inherited it into a class to use the object variables and make the call to that protected class- Good or bad idea?
what security issues are you addressing
17:41
Well, since it holds a lot of global server values ie database username, location, password
I don't want it directly exposed.
I fail to see how making a protected constructor helps
I want to control the variables that are constructed with that class.
I don't want senseless calls or injection.
I'm not familiar with the best form of prevention- that is why I asked.
You can't do security in managed code; almost all language features that control access to code can be bypassed with reflection
access modifiers in C# mean "Please don't, it's really not a good idea"
Good to know, so what would be the best way to help not encourage those variables to be exposed then?
I mean the values are being set by a UI
So I guess I'm just complicating it
@Greg If it is private in the super and child classes then it is fine.
17:45
you can use SecureString to prevent someone from reading the memory but if your db requires a string username it will be there at least for a time
However if a public method returns a reference to a mutable object.. it breaks encapsulation.
Can I post the code and tell me if this is correct?
You can't force someone not to misuse your code. The real question is, what are you trying to do?
and how big is the security threat. If someone is connecting directly to you database you must have some level of implied trust already
Well, since it is web based I'm trying to allow the GUI to be set but when these variables are used I don't want them to be read by like Fiddler or another utility
I want to hide them.
17:48
The input stream is not a valid binary format. The starting contents (in bytes) are: 00-00-09-27-00-00-00-09-28-00-00-00-09-29-00-00-00 ...
Essentially I have empty variables that are used, but once they are used in the login portion of the site then I want it to hide those as they are being used in other areas that the public will access
you can connect over SSL
Greg is this a web app or desktop
It's both
It does desktop remoting and web
It essentially allows someone to manipulate and modify the web server and build cms sites dynamically with prefilled branding and content
But because it prefills data it has to connect to a parent database
does the desktop app connect directly to the db??
it's very difficult to keep your passwords safe on someone else's machine.
Um at the moment yes, but I was hoping to change that
17:54
so the passwords should be safe on the server.
there are things you can do like secure config sections in an app.config and the secure data api in windows
Okay- So if I use a couple of those it should force the data to be slightly more hidden?
I've never had to really work with security in a program, so forgive my naive and ignorance on the subject.
potentially but you shouldn't have to expose those credentials to the client. Plus if someone does break in, how do you distribute the new credentials to valid clients
ideally they send a username and password that identifies the self to the service and you manage their access control from there.
Everything you provide access to, your JavaScript code, your desktop application, everything should be considered 'open-source' because anyone can break in. The server however is not, and is the best place to keep routines 'hidden'.

« first day (965 days earlier)      last day (4205 days later) »