Search Results

Search found 8684 results on 348 pages for 'nunit console'.

Page 96/348 | < Previous Page | 92 93 94 95 96 97 98 99 100 101 102 103  | Next Page >

  • Does this code depend on string interning to work?

    - by Nick Gotch
    I'm creating a key for a dictionary which is a structure of two strings. When I test this method in a console app, it works, but I'm not sure if the only reason it works is because the strings are being interned and therefore have the same references. Foo foo1 = new Foo(); Foo foo2 = new Foo(); foo1.Key1 = "abc"; foo2.Key1 = "abc"; foo1.Key2 = "def"; foo2.Key2 = "def"; Dictionary<Foo, string> bar = new Dictionary<Foo, string>(); bar.Add(foo1, "found"); if(bar.ContainsKey(foo2)) System.Console.WriteLine("This works."); else System.Console.WriteLine("Does not work"); The struct is simply: public struct Foo { public string Key1; public string Key2; } Are there any cases which would cause this to fail or am I good to rely on this as a unique key?

    Read the article

  • What's the deal with the hidden Throw when catching a ThreadAbortException?

    - by priehl
    I'm going through a book of general c# development, and I've come to the thread abort section. The book says something along the lines that when you call Thread.Abort() on another thread, that thread will throw a ThreadAbortException, and even if you tried to supress it it would automatically rethrow it, unless you did some bs that's generally frowned upon. Here's the simple example offered. using System; using System.Threading; public class EntryPoint { private static void ThreadFunc() { ulong counter = 0; while (true) { try { Console.WriteLine("{0}", counter++); } catch (ThreadAbortException) { // Attempt to swallow the exception and continue. Console.WriteLine("Abort!"); } } } static void Main() { try { Thread newThread = new Thread(new ThreadStart(EntryPoint.ThreadFunc)); newThread.Start(); Thread.Sleep(2000); // Abort the thread. newThread.Abort(); // Wait for thread to finish. newThread.Join(); } catch (Exception e) { Console.WriteLine(e.ToString()); } } } The book says: When your thread finishes processing the abort exception, the runtime implicitly rethrows it at the end of your exception handler. It’s the same as if you had rethrown the exception yourself. Therefore, any outer exception handlers or finally blocks will still execute normally. In the example, the call to Join won’t be waiting forever as initially expected. So i wrapped a try catch around the Thread.Abort() call and set a break point, expecting it to hit this, considering the text says "any outer exception handlers or finally blocks will still execute normally". BUT IT DOES NOT. I'm racking my brain to figure out why. Anyone have any thoughts on why this isn't the case? Is the book wrong? Thanks in advance.

    Read the article

  • Shortest Distance From An Array

    - by notyou61
    I have an ajax function which returns the latitudes and longitudes of locations stored in a database. These are returned and placed in an array. A calculation is performed to return their distance from the users current location based on the latitude/longitude. I would like to return only the record with the shortest calculated distance. My code is as follows: Ajax Success // Success success: function (data) { // Obtain Log/Lat navigator.geolocation.getCurrentPosition(function(position) { // Obtain Current Position Lat/Lon glbVar.latitude = position.coords.latitude; glbVar.longitude = position.coords.longitude; // Console Log //console.log('Lat: ' + glbVar.latitude + ' Lon: ' + glbVar.longitude); // Obtain Location Distances for ( var i = 0; i < data.length; i++ ) { // Location Instances var varLocation = data[i]; // Location Distance varLocation.distance = calculateDistance(glbVar.longitude, glbVar.latitude, varLocation.locationLongitude, varLocation.locationLatitude); } // Sort Locations By Distance var sortedData = data.sort(function(a, b) { // Return Locations return a.distance - b.distance; }); // Output Results $.map(sortedData, function(item) { // Obtain Location Distance varLocationsDistance = calculateDistance(glbVar.longitude, glbVar.latitude, item.locationLongitude, item.locationLatitude); // Obtain Location Radius Assignment if (varLocationsDistance <= varLocationRadius) { // Function Return functionReturn = $({locationID : item.locationID + ', Distance : ' + varLocationsDistance + ' m'}); // Return // Function to get the Min value in Array Array.min = function( sortedData ){ functionReturn = Math.min.apply( Math, sortedData ); // console.log(functionReturn); }; } }); }); } The calculateDistance function returns the distance from the users current location and those from the database. The varLocationsDistance <= varLocationRadius "If" statement returns records within a certain distance radius (100 meters), within that statement I would like to return the shortest distance. I am a self taught amateur web developer and as a result may not have provide enough information for an answer, please let me know. Thanks,

    Read the article

  • Basic C# problem

    - by Juan
    Determine if all the digits of the sum of n -numbers and swapped n are odd. For example: 36 + 63 = 99, y 409 + 904 = 1313. Visual Studio builds my code, there is still something wrong with it ( it doesnt return an answer) can you please help me here? using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { long num = Convert.ToInt64(Console.Read()); long vol = voltea(num); long sum = num + vol; bool simp = simpares(sum); if (simp == true) Console.Write("Si"); else Console.Write("No"); } static private bool simpares(long x) { bool s = false; long [] arreglo = new long [1000]; while ( x > 0) { arreglo [x % 10] ++; x /=10; } for (long i=0 ; i <= arreglo.Length ; i++) { if (arreglo [i]%2 != 0) s = true; } return s; } static private long voltea(long x) { long v = 0; while (v > 0) { v = 10 * v + x % 10; x /= 10; } return v; } } }

    Read the article

  • JavaScript sleep

    - by Diazath
    yes, i know - that question has thousands of answers. please, don't tell me about "setTimeout" method becasuse - yes, everything is possible with that but not so easy as using sleep() method. for example: function fibonacci(n) { console.log("Computing Fibonacci for " + n + "..."); var result = 0; //wait 1 second before computing for lower n sleep(1000); result = (n <= 1) ? 1 : (fibonacci(n - 1) + fibonacci(n - 2)); //wait 1 second before announcing the result sleep(1000); console.log("F(" + n + ") = " + result); return result; } if you know how to get the same result using setTimeout - tell me ;) fibanacci is pretty easy task, because there not more than 2 recursions, but how about n-recursions (like fib(1) + fib(2) + .. + fib(n) and sleep after every "+"? nah, sleep would be muuuuuch easier. but still i can't get working example of implementing it. while (curr - start < time) { curr = (...) } is tricky, but it won't work (just stops my browser and then throw all console.logs at once).

    Read the article

  • Why does local variable names take precedence over function names in JavaScripts?

    - by fredrik
    In JavaScript you can define function in a bunch of different ways: function BatmanController () { } var BatmanController = function () { } // If you want to be EVIL eval("function BatmanController () {}"); // If you are fancy (function () { function BatmanController () { } }()); By accident I ran across a unexpected behaviour today. When declaring a local variable (in the fancy way) with the same name as function the local variable takes presence inside the local scope. For example: (function () { "use strict"; function BatmanController () { } console.log(typeof BatmanController); // outputs "function" var RobinController = function () { } console.log(typeof RobinController); // outputs "function" var JokerController = 1; function JokerController () { } console.log(typeof JokerController); // outputs "number", Ehm what? }()); Anyone know why var JokerController isn't overwritten by function JokerController? I tested this in Chrome, Safari, Canary, Firefox. I would guess it's due to some "look ahead" JavaScript optimizing done in the V8 and JägerMonkey engines. But is there any technical explanation to explain this behaviour?

    Read the article

  • Overlaying several CLR reference fields with each other in explicit struct?

    - by thr
    Edit: I'm well aware of that this works very well with value types, my specific question is about using this for reference types. I've been tinkering around with structs in .NET/C#, and I just found out that you can do this: using System; using System.Runtime.InteropServices; namespace ConsoleApplication1 { class Foo { } class Bar { } [StructLayout(LayoutKind.Explicit)] struct Overlaid { [FieldOffset(0)] public object AsObject; [FieldOffset(0)] public Foo AsFoo; [FieldOffset(0)] public Bar AsBar; } class Program { static void Main(string[] args) { var overlaid = new Overlaid(); overlaid.AsObject = new Bar(); Console.WriteLine(overlaid.AsBar); overlaid.AsObject = new Foo(); Console.WriteLine(overlaid.AsFoo); Console.ReadLine(); } } } Basically circumventing having to do dynamic casting during runtime by using a struct that has an explicit field layout and then accessing the object inside as it's correct type. Now my question is: Can this lead to memory leaks somehow, or any other undefined behavior inside the CLR? Or is this a fully supported convention that is usable without any issues? I'm aware that this is one of the darker corners of the CLR, and that this technique is only a viable option in very few specific cases.

    Read the article

  • Cannot understand the behaviour of dotnet compiler while instantiating a class thru interface(C#)

    - by Newbie
    I have a class that impelemnts an interface. The interface is public interface IRiskFactory { void StartService(); void StopService(); } The class that implements the interface is public class RiskFactoryService : IRiskFactory { } Now I have a console application and one window service. From the console application if I write the following code static void Main(string[] args) { IRiskFactory objIRiskFactory = new RiskFactoryService(); objIRiskFactory.StartService(); Console.ReadLine(); objIRiskFactory.StopService(); } It is working fine. However, when I mwrite the same piece of code in Window service public partial class RiskFactoryService : ServiceBase { IRiskFactory objIRiskFactory = null; public RiskFactoryService() { InitializeComponent(); objIRiskFactory = new RiskFactoryService(); <- ERROR } /// <summary> /// Starts the service /// </summary> /// <param name="args"></param> protected override void OnStart(string[] args) { objIRiskFactory.StartService(); } /// <summary> /// Stops the service /// </summary> protected override void OnStop() { objIRiskFactory.StopService(); } } It throws error: Cannot implicitly convert type 'RiskFactoryService' to 'IRiskFactory'. An explicit conversion exists (are you missing a cast?) When I type casted to the interface type, it started working objIRiskFactory = (IRiskFactory)new RiskFactoryService(); My question is why so? Thanks.(C#)

    Read the article

  • Calling function and running it

    - by devs
    I am quite new to objects and OOP. I really don't know how to explain it well but I'll try. So I am trying to read though JSON with JS, the JSON is passed from PHP. This would be easy if all of the information was on the same html page, but I' am trying something that I am new too. So let me show my code... First is the JS which is in app.js var Donors = function(){ var api = this.list; $(document).ready(function(){ $.getJSON(api, function(){ var donorObj = api.payload; $.each(donorObj, function(i, donor){ //console.log(donor.ign); }); }); }); } What I want this part to do is read from the JSON I'm giving it and console.log each name (or donor.ign) when the document is ready. On the html page, or header.php <script> $(function(){ var list = <?php cbProxy(); ?>; var Dons = new Donors(); Dons.list = list; }); </script> the data that's in list is the below JSON. You already know what the rest does, it just passes the JSON to the Donors() function. JSON example: { "code": 0, "payload": [ { "time": 1349661897, "packages": [ "49381" ], "ign": "Notch", "price": "15.99", "currency": "USD" } I'm use to just making functions and calling it on the same page or file and this is my first doing this kind of function. How can I get the function to run with the data I sent it so it console.log() each name.

    Read the article

  • Capture data from jQuery Mobile GUI / form elements like sliders, or the flip switch/toggle, and store in a var?

    - by Carl Foggin
    I have this code, which executes without error, it shows "** slider change **" in the debug console every time the slider changes. But I cannot figure out how to capture the value of the slider so I can store it in a var. Can you help, I'm hoping it's a simple thing. $( '#page4_Options' ).live( 'pageinit', function(event){ var slideTime = userOptions.getSlideTime() / 1000; // userOptions is my Object to get/set params from localStorage. $("input[id='slider']").val(slideTime).slider("refresh"); // set default slide time when page init's. console.log("userOptions.getSlideTime()", userOptions.getSlideTime() ); $( "#slider" ).bind( "slidestop", function(event, ui) { console.log("** slider change **"); // How do I capture the new slider value into a var? }); }); Here's the HTML with the slider, it's in a tag: <div data-role="fieldcontain"> <label for="slider">Slide Duration (seconds):</label> <input type="range" name="slider" id="slider" value="2" min="0" max="60" /> </div>

    Read the article

  • Making a Delete and Reply button in Jquery

    - by Branko Ostojic
    this is my second post on the website. Of all other sites i tried, this one gave the most accurate and useful information! I'm in a bit of a trouble with buttons, i have a task to make an inbox and to add a "reply" and "delete" button into every instance of the message. I was indeed wandering if there is a better way to do that than forcing the HTML code into the script, because every message is dynamically generated. Any help and/or suggestions would be very appreciated!(The objects are called from a JSON file). $(document).ready(function(){ $.getJSON('public/js/data.json', function(json){ $.each(json.data, function(i, data){ var output = ''; if(data.from.id != '234' && data.from.name != 'Alan Ford'){ $("#inbox").append( output += '<div class="post">'+ '<div class="h1">'+data.from.name+' - '+data.subject+'</div>'+ //this gives the name of the person who sent the message and the subject '<div class="content">'+data.message_formatted+'</div>'+ //The content of the message //buttons should be squeezed left of the date //this gives the date of the message sent '<div class="time">'+data.date_sent_formatted.formatted+'</div>'+ '</div>' ); }}); }); }); var date_sent=convertToDateTime(); function delete_message(id){ console.log('Delete message with id: '+id); } function reply_message(id, sender){ console.log('Message id: '+id); console.log('Reply to: '+sender); } The complete code in the JSFiddle . Just copy/pasted!

    Read the article

  • Selecting an option with given value

    - by Maven
    I am trying to select a particular option from a select list depending on the value, I have following markup: <select name="class" id="class"> <option value="1">679460ED-0B15-4ED9-B3C8-A8C276DF1C82</option> <option value="2">B99BF873-7DF0-4E7F-95FF-3F1FD1A26139</option> <option value="3">1DCD5AD7-F57C-414</option> <option value="4">6B0170AA-F044-4F9C-8BB8-31A51E452CE4</option> <option value="5">C6A8B</option> <option value="6">1BBD6FA4-335A-4D8F-8681-DFED317B8052</option> <option value="7">727D71AB-F7D1-4B83-9D6D-6BEEAAB</option> <option value="8">BC4DE8A2-C864-4C7C-B83C-EE2450AF11B1</option> <option value="9">AIR CONDITIONING SYSTEM</option> <option value="10">POWER GENERATION SYSTEM</option> </select> <script> selectThisValue('#class',3); </script> in .js function selectThisValue(element,value) { console.log(value); var elem = $(element + ' option[value=' + value + ']'); console.log(elem); elem.attr("selected", "selected"); } Results for console.log are as follows: 3 [prevObject: i.fn.i.init[1], context: document, selector: "#class option[value=3]", jquery: "1.10.2", constructor: function…] But this is not working, no errors are given but nothing happens also. Please help identifying the where am I wrong.

    Read the article

  • jQuery .ajax method executing but not firing error (or success)

    - by John Swaringen
    I'm having a very strange situation. I have a .NET Web Service (.asmx) that I'm trying to call via jQuery ajax to populate some <select></select>'s. The service is running System.Web.Services like it's supposed to and should be returning a JSON list. At least that's the way I understand that it will in .NET 3.5/4.0. The main problem is that the .ajax() function (below) seems to execute but the internal callbacks aren't executing. I know it's executing because I can do something before and after the function and both execute, so JavaScript isn't blowing up. $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: 'http://localhost:59191/AFEDropDownService/Service.asmx/GetAVP', data: "{}", dataType: "jsonp", crossDomain: true, success: function(list) { console.log(list); console.log("success!!"); }, error: function(msg) { console.log("error: " + msg.text); } }); If you need more of the code let me know. Or if you know a better way as I'm trying to build cascading <select></select's.

    Read the article

  • My HTML5 web app crashes and I have no clue how to debug

    - by Shouvik
    Hi All, I have written a word game using HTML5 canvas tag and a little bit of audio. I developed the application on the chrome web browser on a linux system. Recently during the testing phase it was tried on safari 5.0.3 on Mac and the webpage froze. Not just the canvas element, but interactive element on the page froze. I have at some times experienced this problem on google chrome when I was developing but since the console did not throw any error before this happened, I did not give it much credence. Now as per requirements I am supposed to support both chrome and safari but this dismal performance on safari has left me shocked and I cannot see what error can be thrown which might lead to such a situation. Worse yet the CPU usage on using this application peaks to 70-80percent on my 2yr old macbook running ubuntu... I can only but pity the person who uses mac to operate this app, which undoubtedly is a heavier OS. Could someone help me out with a place I can start with to find out what exactly is causing this issue. I have run profiles on this webapp on google chromes console and noticed that in the heap spanshot value increases steadily with the playing of the game, specifically (root) value which jumps up by 900 counts. Any help would be very appreciated! Thanks EDIT: I don't know if this helps, but I have noticed that even on refreshing the page after the app becomes unresponsive the page reloads and I am still not able to interact with the page elements but the tab scroll bar continues to work and I can see my application window completely. So to summaries the tab stops accepting any sort of user interaction inside the page. Edit2: Nop. It doesn't work still... The app crashes on double click on the canvas element. The console is not throwing any errors either! =/ I have noticed this problem is isolated only to safari!

    Read the article

  • Changing the value of a variable

    - by neirpycc
    I'm trying to build a simple scoring app but I'm running into a problem trying to keep it so I don't have to repeat a bunch of code to deal with each 'base' individually. The basic idea is that when I click a button the script will; 1) grab the ID of said button 2) split the ID into two parts - (a) the bases name and (b) the button type (plus/minus) 3) if it's plus - add to the bases score, if it's minus - subtract from the bases score 4) update the assigned div with the new value The part I'm stuck at is adding and subtracting. I can't seem to get this to work. Here is the code: $('.base button').click(function() { var b1Score = 0; var b2Score = 0; var b3Score = 0; var b4Score = 0; var b5Score = 0; var clickedButton = $(this).attr('id'); var buttonInfo = clickedButton.split('-'); var baseClicked = buttonInfo[0]; var baseDirection = buttonInfo[1]; var baseDiv = ('#' + baseClicked); console.log('You clicked ' + clickedButton + '.'); if (baseDirection.indexOf('plus') >= 0) { console.log('Increasing ' + baseClicked + '!'); ++; $(baseDiv).val(); } else { console.log('Decreasing ' + baseClicked + '!'); --; $(baseDiv).val(); } }); ++; and --; are placeholders for where the adding and subtracting needs to happen. I just can't figure out how to get it to add or subtract from the correct value. Any help is appreciated. Thanks.

    Read the article

  • AngularJS: Using Shared Service(with $resource) to share data between controllers, but how to define callback functions?

    - by shaunlim
    Note: I also posted this question on the AngularJS mailing list here: https://groups.google.com/forum/#!topic/angular/UC8_pZsdn2U Hi All, I'm building my first AngularJS app and am not very familiar with Javascript to begin with so any guidance will be much appreciated :) My App has two controllers, ClientController and CountryController. In CountryController, I'm retrieving a list of countries from a CountryService that uses the $resource object. This works fine, but I want to be able to share the list of countries with the ClientController. After some research, I read that I should use the CountryService to store the data and inject that service into both controllers. This was the code I had before: CountryService: services.factory('CountryService', function($resource) { return $resource('http://localhost:port/restwrapper/client.json', {port: ':8080'}); }); CountryController: //Get list of countries //inherently async query using deferred promise $scope.countries = CountryService.query(function(result){ //preselected first entry as default $scope.selected.country = $scope.countries[0]; }); And after my changes, they look like this: CountryService: services.factory('CountryService', function($resource) { var countryService = {}; var data; var resource = $resource('http://localhost:port/restwrapper/country.json', {port: ':8080'}); var countries = function() { data = resource.query(); return data; } return { getCountries: function() { if(data) { console.log("returning cached data"); return data; } else { console.log("getting countries from server"); return countries(); } } }; }); CountryController: $scope.countries = CountryService.getCountries(function(result){ console.log("i need a callback function here..."); }); The problem is that I used to be able to use the callback function in $resource.query() to preselect a default selection, but now that I've moved the query() call to within my CountryService, I seemed to have lost what. What's the best way to go about solving this problem? Thanks for your help, Shaun

    Read the article

  • Cannot understand the behaviour of C# compiler while instantiating a class thru interface

    - by Newbie
    I have a class that implements an interface. The interface is public interface IRiskFactory { void StartService(); void StopService(); } The class that implements the interface is public class RiskFactoryService : IRiskFactory { } Now I have a console application and one window service. From the console application if I write the following code static void Main(string[] args) { IRiskFactory objIRiskFactory = new RiskFactoryService(); objIRiskFactory.StartService(); Console.ReadLine(); objIRiskFactory.StopService(); } It is working fine. However, when I mwrite the same piece of code in Window service public partial class RiskFactoryService : ServiceBase { IRiskFactory objIRiskFactory = null; public RiskFactoryService() { InitializeComponent(); objIRiskFactory = new RiskFactoryService(); <- ERROR } /// <summary> /// Starts the service /// </summary> /// <param name="args"></param> protected override void OnStart(string[] args) { objIRiskFactory.StartService(); } /// <summary> /// Stops the service /// </summary> protected override void OnStop() { objIRiskFactory.StopService(); } } It throws error: Cannot implicitly convert type 'RiskFactoryService' to 'IRiskFactory'. An explicit conversion exists (are you missing a cast?) When I type cast to the interface type, it started working objIRiskFactory = (IRiskFactory)new RiskFactoryService(); My question is why so?

    Read the article

  • Why I cannot get the output of ftp.exe ?

    - by smwikipedia
    I execute the ftp.exe cmd through a C# System.Diagnostics.Process type. And I use the following code to get the "ftp.exe" output after I programmatically enter a "help" command. But I can only get the first line of the result. And I never get to the "end" output part. The whole program seems blocked. Process p = new Process(); p.StartInfo.FileName = @"C:\Windows\System32\ftp.exe"; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.UseShellExecute = false; p.Start(); p.StandardInput.WriteLine("help"); Int32 c_int = p.StandardOutput.Read(); while (c_int != -1) { Char c = (Char)c_int; Console.Write(c); c_int = p.StandardOutput.Read(); } Console.WriteLine("end"); However, I write a simple program which only use Console.Writeline() to write some output to its StdOut stream. And I test it with the above code. It works fine. I just cannot figure out why the above code cannot work with ftp.exe? The only difference between my SimpleConsoleOutput program and the "ftp.exe" is that the ftp.exe has its own interactive command prompt.

    Read the article

  • how to filter selected objects then hide objects not selected.

    - by ussteele
    following up from yesterday... This portion of the code does work. $(document).ready(function(){ $('#listMenu a').click(function (selected) { var getPage = $(this).attr('id'); var getName = $(this).attr('name'); //console.log(getPage); //console.log(getName); $(function() { $("#" + getName ).show(); var getColor = $('#' + getName ).css('background-color'); $('#header' ).css('background', getColor); $('#slideshow' ).css('background', getColor); $('span').css('background', getColor); $('#menuContainer').css('background', getColor); }); $('li.listMenu ul').hide(); }); }); I am able to get what I wanted selected; based on vars getPage and getName, now I need to hide what is not selected. I have tried this: $(function() { var notSelected = $('div').filter(selected).attr('id', 'name'); $(this).hide(); console.log(notSelected); }); placed just above: $('li.listMenu ul').hide(); but it's not correct, remember I am really a newbie. what I see on screen is the new selected items on top of what should be hidden. again any help is appreciated. -sjs

    Read the article

  • Generic Event Generator and Handler from User Supplied Types?

    - by JaredBroad
    I'm trying to allow the user to supply custom data and manage the data with custom types. The user's algorithm will get time synchronized events pushed into the event handlers they define. I'm not sure if this is possible but here's the "proof of concept" code I'd like to build. It doesn't detect T in the for loop: "The type or namespace name 'T' could not be found" class Program { static void Main(string[] args) { Algorithm algo = new Algorithm(); Dictionary<Type, string[]> userDataSources = new Dictionary<Type, string[]>(); // "User" adding custom type and data source for algorithm to consume userDataSources.Add(typeof(Weather), new string[] { "temperature data1", "temperature data2" }); for (int i = 0; i < 2; i++) { foreach (Type T in userDataSources.Keys) { string line = userDataSources[typeof(T)][i]; //Iterate over CSV data.. var userObj = new T(line); algo.OnData < typeof(T) > (userObj); } } } //User's algorithm pattern. interface IAlgorithm<TData> where TData : class { void OnData<TData>(TData data); } //User's algorithm. class Algorithm : IAlgorithm<Weather> { //Handle Custom User Data public void OnData<Weather>(Weather data) { Console.WriteLine(data.date.ToString()); Console.ReadKey(); } } //Example "user" custom type. public class Weather { public DateTime date = new DateTime(); public double temperature = 0; public Weather(string line) { Console.WriteLine("Initializing weather object with: " + line); date = DateTime.Now; temperature = -1; } } }

    Read the article

  • Why I cannot get the output of ftp.exe by code?

    - by smwikipedia
    I execute the ftp.exe cmd through a C# System.Diagnostics.Process type. And I use the following code to get the "ftp.exe" output after I programmatically enter a "help" command. But I can only get the first line of the result. And I never get to the "end" output part. The whole program seems blocked. Process p = new Process(); p.StartInfo.FileName = @"C:\Windows\System32\ftp.exe"; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.UseShellExecute = false; p.Start(); p.StandardInput.WriteLine("help"); Int32 c_int = p.StandardOutput.Read(); while (c_int != -1) { Char c = (Char)c_int; Console.Write(c); c_int = p.StandardOutput.Read(); } Console.WriteLine("end"); However, I write a simple program which only use Console.Writeline() to write some output to its StdOut stream. And I test it with the above code. It works fine. I just cannot figure out why the above code cannot work with ftp.exe? The only difference between my SimpleConsoleOutput program and the "ftp.exe" is that the ftp.exe has its own interactive command prompt.

    Read the article

  • bubble sort logic error

    - by Arianule
    I was trying a basic sorting exercise and I was hoping I could receive some help with what is probably a basic logic error. int[] numbers = new int[] { 2, 5, 11, 38, 24, 6, 9, 0, 83, 7 }; for (int loop = 0; loop < numbers.Length; loop++) { Console.WriteLine(numbers[loop]); } Console.WriteLine("Performing a bubble sort"); bool flag = false; do { for (int loop = 0; loop < numbers.Length - 1; loop++) { if (numbers[loop] > numbers[loop + 1]) { int temporary = numbers[loop]; numbers[loop] = numbers[loop + 1]; numbers[loop + 1] = temporary; flag = true; } } } while (flag == false); for (int loop = 0; loop < numbers.Length; loop++) { Console.WriteLine(numbers[loop]); } kind regards arianule

    Read the article

  • jQuery accessing objects

    - by user1275268
    I'm trying to access the values of an object from a function I created with a callback, but have run into some trouble. I'm still fairly new at jQuery/javascript. I call the function as follows: siteDeps(id,function(data){ $.each(data,function(key,val) { console.log(key); console.log(val); }); }); The function runs 5 ajax queries from XML data and returns data as an multidimensional object; here is a excerpt showing the meat of it: function siteDeps(id,callback) { var result = { sitecontactid : {}, siteaddressid : {}, sitephoneid : {}, contactaddressid : {}, contactphoneid : {} }; ...//.... var url5 = decodeURIComponent("sql2xml.php?query=xxxxxxxxxxx"); $.get(url5, function(data){ $(data).find('ID').each(function(i){ result.delsitephoneid[i] = $(this).text(); }); }); callback(result); } The console.log output shows this: sitecontactid Object 0: "2" 1: "3" __proto__: Object siteaddressid Object 0: "1" __proto__: Object sitephoneid Object 0: "1" 1: "5" 2: "54" __proto__: Object contactaddressid Object 0: "80" __proto__: Object contactphoneid Object 0: "6" __proto__: Object How can I extract the callback data in a format I can use, for instance sitephoneid: "1","5","54" Or is there a better/simpler way to do this? Thanks in advance.

    Read the article

  • SelectQuery eating up 100% CPU

    - by modernzombie
    I am doing a query for all the users on the machine and when it executes it grabs 100% CPU and locks up the system. I have waited up to 5 minutes and nothing happens. In the Task Manager wmiprvse.exe is using all the CPU. When I kill that process everything returns to normal. Here is my code: SelectQuery query = new SelectQuery("Win32_UserAccount", "LocalAccount=1 and Domain='" + GetMachine().DomainName + "'"); using(ManagementObjectSearcher searcher = new ManagementObjectSearcher(query)) { IList<WindowsUser> users = new List<WindowsUser>(); Console.WriteLine("Getting users..."); foreach (ManagementObject envVar in searcher.Get()) { Console.WriteLine("Getting " + envVar["Name"].ToString() + "..."); } } In the console all I see is Getting users... and nothing else. The problem appears to be with searcher.Get(). Does anyone know why this query is taking 100% CPU? Thanks. EDIT: OK I found that it the WMI process is only eating 25% CPU but it doesn't get released if I end the program (the query never finishes). The next time I start an instance the process goes up to 50% CPU, etc, etc until it is at 100%. So my new question is why is the CPU not getting released and how long should a query like this take to complete?

    Read the article

  • CodePlex Daily Summary for Saturday, March 20, 2010

    CodePlex Daily Summary for Saturday, March 20, 2010New ProjectsaMaze Mapa Generator: Parte do Projeto aMazeASP.Net RIA Controls: Simple ASP.Net server controls to integrate Flash and Silverlight controls into your web applications. Included controls don't use any JavaScript,...BMap.NET: BMaps.NET is a .NET application written in C#, for access Bing Maps from your computer without web browsers. With it you can access to Bing Maps an...DaliNet: A .NET API for the Tridonic.Atco DALI USB device.Fabrica7: This is the main project of Fabrica 7 Corp.Image Ripper: A Winform application parse & fetch various HD pictures in specific photo galleries.IoCWrap: Provides interfaces which wrap various IoC container implementations so that it is possible to switch to a different provider without changing any ...NetSockets: NetSockets is a .NET class library that provides easy-to-use, multi-threaded, event-based, client and server network communication.Network Backup: Network Backup is a home and small company backup solution for workstations and a backup server. It incorporates a backup service, scheduler, data ...NUnit.Specs: Specification extensions for NUnit.Nutrivida: Sistema para avaliação de especialização.OHTB Snake: OHTB Snake is a multiplayer game. In this incarnation, snakes may eat 3 types of powerups: standard berries, causing them to grow; sawberries, caus...Playground TDrouen: Tjerk's PlaygroundPower Plan Chooser: This is my first endeavor into a C# Windows application with XAML. The program sits in the notification area (task bar) and lets you quickly activa...Search IMDB in C#: In lack of an IMDB API most of us resort to screen scraping utilities to query the Internet Movie Database. This one is written in C# (.NET 2.0 sta...SIGPRO Desktop: FUNCERNSql2008 PerfMonCounter Fix: Small console application to Fix the SQL 2008 Express Edition installation error: Pequena aplicação para Corrigir o seguinte erro de Instalação do...TwiztedTracker: TwiztedTracker designed to make your bug tracking easy.UmbracoXsltLogHelper: I needed a way to easily add log rows from my xslt macros, and added a single-line-extension for that reason. Then I played around with the umbraco...VisualStock: VisualStock is stock data visualization, analysis application build on the Micorsoft Composite Application Library.WHS File Mover: A Windows Home Server Plugin to move files from a local directory ("drop" or "staging" directory to a folder share)XML based Content Deployment in SharePoint: XML based Content Deployment in Sharepoint helps you to easy deploy content into SharePoint, including webs, lists, items, files and folder. You wi...New ReleasesASP.Net RIA Controls: Version 1.0 Beta: The first functionnal version.BMap.NET: BMap.NET 1: This is the 1st version of BMap.NETDigital Media Processing Project 1: Image Processor: Image Processor 1.0: All features implemented. Added: clipping imageFamily Tree Analyzer: Version 1.3.1.0: Version 1.3.1.0 Added a cancel button to marriage and children IGI Searches Opening Results window now automatically shows first record Updated IGI...Free Silverlight & WPF Chart Control - Visifire: Visifire SL and WPF Charts 3.0.5 Released: Hi, This release contains fix for the following bug: * Chart threw exception if ZoomingEnabled property was set to True at real-time. You ca...Homework Helper: Homework Helper v.1.1: Sorry but the latest release didn't seem to be the latest. This should be the right one!Image Ripper: Image Ripper: Image Ripper based on HtmlAgilityPack and GData library.ManPowerEngine: 0.1: UpdatesSound System added. Bitmap Collider in Physics System works now. Improved the performance of HTTP download in images Physics Framework...NIPO Data Processing Component Framework: NIPO 1.0: The first release of NIPO. Includes the NIPO binary dll and documentation. This release does not include a starter application since it is still in...patterns & practices SharePoint Guidance: SPG2010 Drop7: SharePoint Guidance Drop Notes Microsoft patterns and practices ****************************************** ***************************************...Photosynth Point Cloud Exporter: Photosynth Point Cloud Exporter 1.0.2: Photosynth webservice reference updated to work with the new site OBJ file format support added (Note: this format doesn't support vertex colors)Power Plan Chooser: Power Plan Chooser 1.0.0: Power Plan Chooser is a small utility that sits in the notification area (task bar) in Windows 7 and allows the user to quickly activate one of the...Restart Explorer: RestartExplorer Release 1.00.0001: Initial release: Start, stop and restart Windows Explorer with this utility.Search IMDB in C#: Search IMDB 1.0: Source code included with compiled example.SIMD Detector: 3rd Release: Added Intel AES instruction check Added a CSharp Winform NetSIMDDetector application. Changes the red ball and green ball images to red cross a...Sql2008 PerfMonCounter Fix: Sql2008FIx_PerfMonCounter.zip: Small console application to Fix the SQL 2008 Express Edition installation error: http://support.microsoft.com/kb/300956 Rule Name PerfMonCounter...UmbracoXsltLogHelper: 0.9 Working Beta: First version. XsltLogHelper09 is the installable package.VCC: Latest build, v2.1.30319.0: Automatic drop of latest buildWCF RIA Services Contrib: RIA Services Contrib RC Release: This version is recompiled against the RC release of WCF RIA Services.XML based Content Deployment in SharePoint: SPContentDeployment 1.0.0.0: The first link contains the resources and a sample project. The second link contains everything included in the first package and an additional fo...Yet Another GPS: YAGPS Alfa.2: Yet another GPS tracker is a very powerful GPS track application for Windows Mobile Speed Guage, Sat Count number, KML for google map file formatZGuideTV.NET: ZGuideTV.NET 0.92: Vendredi 19 mars 2010 (ZGuideTV.NET bêta 9 build 0.92) - English below Corrections : - Gestion de certains contrôles dans l'écran principal. - Div...Most Popular ProjectsMetaSharpRawrWBFS ManagerSilverlight ToolkitASP.NET Ajax LibraryMicrosoft SQL Server Product Samples: DatabaseAJAX Control ToolkitLiveUpload to FacebookWindows Presentation Foundation (WPF)ASP.NETMost Active ProjectsLINQ to TwitterRawrOData SDK for PHPjQuery Library for SharePoint Web ServicesDirectQPHPExcelpatterns & practices – Enterprise LibraryBlogEngine.NETFarseer Physics EngineNB_Store - Free DotNetNuke Ecommerce Catalog Module

    Read the article

< Previous Page | 92 93 94 95 96 97 98 99 100 101 102 103  | Next Page >