« first day (1411 days earlier)      last day (3546 days later) » 

9:04 PM
does anybody know how to run all tests without building all before?
 
@Nathvi why would you want to..?
 
@ReedCopsey Can you explain that code from a couple days ago?
 
can you link/paste it?
it should be pretty straightforward
 
Well, I was more curious about the comment you made where you said "this doesn't make sense". @NETscape explained that .Contains returns a bool which more than likely wasn't what I wanted to select data.
internal class LogItem
{
    public DateTime Date { get; set; }
    public string Title { get; set; }
    public string Priority { get; set; }
    public string Message { get; set; }
}

public class LogToTextfile : ILogger
{
    private BlockingCollection<LogItem> queue = new BlockingCollection<LogItem>();
    private bool running = false;

    private void Start()
    {
        var th = new Thread(() =>
        {
            var filename = ConfigurationManager.AppSettings[@"TextLog"];
            foreach(var log in queue.GetConsumingEnumerable())
 
Sorry I don't get it
Lol :)
Maybe you need Equals?
 
9:16 PM
@Pheonixblade9, coz :v
 
Unless the string is a damn long string
@Greg Like "I has Priority"
But then what if you had "Title Priority Message"
 
what is the question?
ps - writing your own logging is generally a smell.
imo
log4net and nlog are usually the go-to's
 
^
We use log4net heavily at work in fact
 
we use MOM logs
 
there's nice things with those frameworks as well
such as, if i do log.Debug("some big format string {0} {1}", param1, param2)"
it checks that debug is enabled before building the string
 
9:19 PM
@Greg Your log was effectively "Some Date, True, True, False"
not anything about the Title
 
which is kinda nice - and these people have time to think about those sorts of things
 
Contains returns True or False
that's it ;)
 
@ReedCopsey Oh wow.. totally off the mark :)
 
also - above code has a small race condition how its written. should be a do-while and not a foreach
 
Mehhhn I can never be a software architect lol
 
9:20 PM
@drch do while where?
 
@drch Isn't the consuming enumerable thread safe?
 
yeah :)
 
AppendAllText is locking, I thought
 
I'm curious where you think the race condition is, @drch
 
@ReedCopsey i mean if the current thread is running while the logs are being written, and new things are added to the collection, the foreach wont pick them up
so its possible that log messages will remain in the 'buffer' between calls
perhaps race condition isnt the right term. but an unexpected state
 
9:21 PM
@drch GetConsumingEnumerable on BlockingCollection never ends (until you flag the BC to be done)
nothing gets lost
that foreach "never ends" in the above code - nothing will get missed
 
ah righto - my brain didn't process that. i just saw the foreach
 
(it starts the thread once, and forever processes the queue, basically as fast as possible)
 
carry on ;)
 
yeah - it should be threadsafe as written :)
 
altho -- technically, after a STart() call, the thread could process the empty queue
and then the messages would be added
so there's a potential race there as well, no?
 
9:23 PM
It won't return IIRC
It will wait until there is data
 
does .GetConsumingEnumerable block until there's data?
 
I believe so
 
ok then
 
> . The enumerator will continue to provide items (if any exist) until IsCompleted returns true, and if IsCompleted is false the loop blocks until an item becomes available or until the CancellationToken is cancelled.
 
ah right - its supporting producer/consumer
 
9:25 PM
Yup
 
ok - last race condition argument - you could in theory spawn two threads ;)
isrunning should perhaps be marked as volatile
 
Mmn I suppose :)
Or CancellationToken be used
Perhaps a Task would be better than thread here
 
i would spawn the thread up-front, rather than doing it in the log function
youre not really saving anything by spinning up the thread on demand.
loggers gonna log
 
@drch Mmn actually volatile isn't needed
It isn't been used in the thread anyway
 
@LewsTherin two calls at the same time to LogMessage could both read isRunning = false and spin up the thread
 
9:32 PM
Mmn right I see
@drch Agreed
 
@ReedCopsey So what should I use then if I'm looking to select data out of the params string[]
 
@Greg It isn't about what you are selecting, but what you are logging
Log 8/27/2014, True, True, False
 
yeah - what does a call to that method look like?
 
If I were app support .. what does that mean?
 
would be nicer to send a real object
 
9:38 PM
It tells me nothing at all
 
@LewsTherin That isn't what I want- What I want is actual information.
 
@Greg Do you know the index of the element in the array at all times?
 
But I'm grabbing based on "Title: ------" is present.
@EvanL No, because it should be a giant list of populated log data.
 
@Greg Who is going to use the log data? What will it be used for?
 
@LewsTherin To log to a database, text file, etc. whatever it needs to be logged to.
 
9:41 PM
You're going to have to verify that the string Contains() Title, figure out what element of the array has that tag, then show the string following the : on that element.
 
@Greg It just seems like raw data to me. And not something that can be used as information. Maybe you should verify the business case with your lead
 
@LewsTherin Define raw data?
 
Is it going to be simple to update from Visual Studio "14" to the released version of the new visual studio?
 
Man, I'm so glad True Blood is done.. now I don't have to feel guilty watching that mind numbing TV
 
@LewsTherin It is used primarily for the application.
@LewsTherin To track errors or issues that may occur.
 
9:42 PM
@Greg According to Wiki
 
@Greg Depends on how he string is setup - but it seems weird to have params in there, and expect data differently
 
> Raw data
Raw data (also known as primary data) is a term for data collected from a source. Raw data has not been subjected to processing or any other manipulation, and are also referred to as primary data.
 
you'd have to show us examples of what's going in
 
or is it typically easy? or should I just go with Visual Studio 2013 for now and wait for the official release?
 
@ReedCopsey Well, if I log to the Windows Event System I don't need a priority or date, it will be handled by that. If it logs to a database I'd use all of the data, same applies for a text file. Rather then building separate models.
In most cases I'll want all four, but in a couple I won't.
 
9:44 PM
again, you're not showing us what you're passing in
so we can't help you
ie: write the code that's going to call this method, and show us that
 
Title: Build Customer
Date: August 27th, 2014
Priority: High
Message: A fatal error occurred in this region, blah, blah.
 
why params string[] and not just a string?
and would that be passed in as 4 separate strings?
 
@ReedCopsey Four separate strings.
 
if so, why not just do: Log(string title, DateTime date, string priority, string message) ?
 
bingo @ReedCopsey
 
9:46 PM
@ReedCopsey Trying to teach myself anonymous types.
 
the user shouldn't care (or know) where the end log target goes
 
@ReedCopsey Linq
 
that has nothing to do with anonymous types or LINQ
 
@Greg Where are you using anonymous types?
 
yesterday, by NETscape
why not just do LogMessage(string title, int priority, string info)?
 
9:47 PM
params is not anonymous typing.
 
I'm trying to learn building an anonymous data model basically.
 
@NETscape lol
 
@Greg but that doesn't make sense here, because you're expecting a fixed model on the resulting side
 
@EvanL No, but the Select(obj = > new { }) would be.
 
taking away typing, only to try to force it back on, just causes pain
@Greg yeah -b ut that won't work as input here anyways :p
 
9:48 PM
You could use a generic parameter and log that directly.
 
and anonymous types are stupid anyways
 
Provided it overrides ToString() sufficiently
 
you should never pass anonymous types through an API boundary
 
Aye it creates un-necessary coupling and breaks Interface Segregation
 
Well, the reason I chose a param string[] as the data could be varied then in each Dependency Injection implementation I could handle the data how it should be passed on that implementation.
 
9:49 PM
that doesn't make sense
the entire point of DI is that the user passing data doesn't know what implementation it is
 
if I consumed your API, and saw param string[] messages or something to that effect, I would blow my brains out.
 
or care - so you'd effectively make it so you're violating Liskov Substitution Principle
 
Fair enough, how should I do it correctly then?
 
decide what to log, and make the API pass that in
the implementation can ignore things all it wants
 
I would say, "what strings am I really supposed to send this thing". And when it didn't work I would be submitting an issue to your github, posting on SO, just implement my own, or find another one
 
9:52 PM
@ReedCopsey Well, if I were to do it normally I would pass a data model called Log which was a series of properties.
 
then just do that :)
and have the implementation use what it wants
 
The goal was to become better with async, anonymous types, linq, and lambda.
That is why I was writing it that way.
@ReedCopsey My goal was to build a massive list of log data, but handle them with async so it separates away from the rest of the API and can finish when it finishes. Since IO can be so slow.
Is that wrong?
 
@Greg No, that's fine - and what I posted above would work fort hat
 
-4
Q: Moving large files to different directory

newbieCSharpI have a 10 GB folder(myfolder) that has lot of files used in an web application. Every week, this gets recreated in a different folder(mynewfolder). I want to move old files to a diff directory and move newly created ones to the right folder without user noticing (or very less down time). I can ...

 
but pass in the data you want logged
 
9:55 PM
@ReedCopsey So I really don't need the .Contains at all?
 
nope
that's why I said it makes no sense in the comment
 
So, I should really just pass the LogModel then.
 
do you need this to be thread safe on the calling side?
 
@ReedCopsey My Log?
@ReedCopsey Whats the difference?
 
If so, I'd do something like:
public class LogItem
{
    public DateTime Date { get; set; }
    public string Title { get; set; }
    public string Priority { get; set; }
    public string Message { get; set; }
}

public class LogToTextfile : ILogger
{
    private BlockingCollection<LogItem> queue = new BlockingCollection<LogItem>();

    public LogToTextfile()
    {
        var th = new Thread(() =>
        {
            var filename = ConfigurationManager.AppSettings[@"TextLog"];
            foreach(var log in queue.GetConsumingEnumerable())
 
10:00 PM
if I say,
LogMe nevermind
 
the way I had it before there was a race condition if you'd be calling LogMessage from multiple threads
this takes away the lazy instantiation, but fixes the race condition - you could use Lazy<T> if you need it to be lazy, though
 
@ReedCopsey What is proper though?
@ReedCopsey I'm really, really trying to learn correctly.
 
@Greg You would definitely want to avoid the race condition. The piece about lazy instantiation is more of a case by case basis.
 
@EvanL Okay. I want to improve so that is why learning and implementing correctly is so important to me.
 
10:21 PM
@Greg I hear ya man. Sometimes "right" is just a matter of what architecture you have decided on.
 
@Greg Reed is referring to chat.stackoverflow.com/transcript/message/18486250#18486250. It's getting rid of the lazy instantiation in that it's going to start the thread right away instead of "when its needed"
 
Meaning, if you need lazy instantiation, then it's the right way. But it's not always the best depending on the situation. We run into issues all the time where we use lazy singletons, but then they hang around when we needed them to be destroyed.
 
so in the most recent implementation, he's spinning the thread when the logger is created. In the implementation from yesterday, it was going to be lazy instantiated because he was calling Start() only when the LogMessage was getting called
 
@NETscape what in your opinion is better? In this case I would think you wouldn't really want the thread around unless you actually wanted it to start. Otherwise it just sits there listening to nothing until someone maybe calls it.
 
the difference, you don't necessarily have to spin up a thread if LogMessage was never called
If someone is going to create a logger, they will more than likely will end up logging something, so I would get rid of the lazy instantiation.
depends also on who your logger is targeted for too I guess
if someone is doing very intensive work in their application, they are going to want to use as "few" resources as possible.
a logger can go either way
@EvanL
 
10:37 PM
@NETscape True, I guess I didn't really understand that Greg's program was just a logger.
 
@NETscape @EvanL Ugh, code I've got to maintain where someone just left, left me a jewel. A return that is over three hundred lines long. I've got garbage like this all over: ?
 
@Greg That's what I fear from our SDK team... pretty much everything they write is a "Hack" and then it just gets pushed up to our app layer and we're supposed to use it...
been blocked all day because of SDK issues...
 
room topic changed to C#: I can't believe it's not broken! [.net] [asp.net] [asp.net-mvc] [c#] [entity-framework] [linq] [visual-studio] [wcf] [wpf]
 
that's why I write all aspects of my project. when i get up to go fight the SDK team I just run my head into the wall.
 
@EvanL Yeah, totally sucks...
 
10:58 PM
I just want 10k rep so I can view deleted crap :(
 
Someone please help me
 
@DemCodeLines with..?
 
c# ;)
Scrolling a ListView CollectionViewSource to a group of items based on a search textbox's text in C#
Forget the search textbox, is there anyway to get the text in each group and a way to scroll the listview down to them?
@Pheonixblade9 Is it something you can help with?
 
Did you write a question on Stack Overflow for it?
 
No, although I guess I should have.
The problem is that it deals with WinRT and I don't think there are many people on SO to help with that.
 
11:04 PM
Still should do that before asking here.
at the very least, write up a question there and post it here.
 
I'll go and write it.
 
if you can't be arsed to write up a question, it seems a bit presumptuous to ask us to answer it :P
cool
 
@Pheonixblade9 Do they show you all deleted stuff?
 
11:17 PM
0
Q: Scrolling a ListView CollectionViewSource to a group of items based on a search textbox's text in C#

DemCodeLinesI am working on a Windows Phone 8.1 app in XAML and C#. I have a listview, whose item source is set to a CollectionViewSource called MusicSource. On the backend in C#, I have an ObservableCollection called source and the following code populates it by getting getting all the music files on the p...

@Pheonixblade9 there you go.
 
@Pheonixblade9 You don't want 10K because that means you can see flagged crap
 
Exactly what I expected, no one even looking at it lol
 
11:42 PM
balls, accidentally opened my work project instead of my toy project
 
@KendallFrey accidently open the link above...
 
@DemCodeLines not many of us are big on XAML here
 
I know XAML, but not WP, and don't have time to answer anything right now
 
@Pheonixblade9 Yeah, but it's primarily C#. I posted XAML in the question so someone doesn't come downvoting it and complaining that I didn't put the XAML part of the problem there.
@KendallFrey Not to be rude or anything, but the question has nothing to do with WP apart from the fact that they both share XAML.
Plus, it's primarily a C# question.
 
ah
well ping me tomorrow if you don't get an answer
 
11:50 PM
:( ok
 

« first day (1411 days earlier)      last day (3546 days later) »