Friday, 15 August 2014

c# - Calling multiple methods asynchronously -


Is there any way to call many methods at the same time? I have a Winform app that loads an unreliable amount of data on loading:

  Private Zero Form 1_load (Object Sender, EventEurge E) {LoadValues1 (); LoadValues2 (); LoadValues3 (); LoadValues4 (); LoadValues5 (); LoadValues6 (); LoadValues7 (); LoadValues8 (); }   

These methods have been retrieved and DevExpress LookUpEdits (similar to Windows Dropdownlists) have been populated, so they all look like this:

  DBContext dbContext = new DBContext); ObservableCollection & LT; String & gt; Values1 = New Observational Collection & lt; String & gt; (I.Value1 i.Value1 for i.Value1! = Null & amp; i.Value1.Length & gt; order in dbContext.Items (from i). Undoubtedly ()); Lookup vouchers 1 Properties Datasource = Dismissed year; DevExpress.XtraEditors.Controls.LookUpColumnInfoCollectioncolInfo = Lookup Value1 Properties Column; ColInfo.Clear (); ColInfo.Add (New DevExpress.XtraEditors.Controls.LookUpColumnInfo ("Columns")); ColInfo [0]. Caption = "value1";   

And some of these methods take some time to complete, yet none of them depend on each other, so I thought I could do them at the same time :

  Tasks. Factor Start (-) => load value 1 ()); Work.factor STARTNU (() => LOAD VALUE 2 ()); e.t.c.   

But when the second work is going on, I keep getting an error, and saying that no control can be made from a separate thread that was created on it.

As you have stated, you need to make sure that When accessing UI elements, you need to make sure that you do it on proper reading. It is so easy to use the Task Parallelism library:

  Private Task Scheduler m_TaskScheduler = TaskScheduler.FromCurrentSynchronizationContext ();   

Once you have a task scheduler, you can schedule your tasks to run on the UI thread like this:

  Task. Factor Start New (() = & gt; {Load Values ​​1 ();}, Cancellation Token One, Functioning Option .nm, M_ Task Scheduler);   

Here's the warning that running all your works on the UI thread can still lock things up to you. I recommend that you create a set of categories or collections of certain types , In which you can populate relevant information and once all the data is for you to call another method on the UI thread, which adds your control to the data or whatever specific actions you need Are necessary.

.net - SQL Sever Java Compatible GUID / UUID (Big Endian UniqueIdentifier) -


I am trying to convert a 128 bit binary to a unique identifier in SQL that is similar to Net and Java is. / P>

I know that Java uses big endians, so I want to make that base.

I can get a gap in the right nant, but in reality I am struggling with it in SQL Server.

Java:

  byte [] bytesformase = "google.com" .getBytes ("UTF-8"); MessageDigest MD = MessageDigest.getInstance ("MD5"); Byte [] md5 = md.digest (bytesfomes); Bytebuffer BB = Bitebuffer. Wet (MD5); Longbuffer ig = BB Longbuffer (); Come back to the new UUID (ig.get (0), ig.get (1));   

1d5920f4-b44b-27a8-02bd-77c4f0536f5a returns

. Net

  System.Security.Cryptography.MD5 c = System.Security.Cryptography.MD5.Create (); Byte [] B = C. Compute hash (encoding.utf.getbites ("google.com")); Int z = System.Net.IPAddress.HostToNetworkOrder (BitConverter.ToInt32 (B, 0)); Less y = System.Net.IPAddress.HostToNetworkOrder (Bitcoin.ToInt16 (B, 4)); Small x = System.Net.IPAddress.HostToNetworkOrder (Bitcutone to.Int16 (b, 6)); Guid G = New Guid (z, y, x, b.Skip (8) .oir ()); Greetings;   

1d5920f4-b44b-27a8-02bd-77c4f0536f5a returns

sql

  DECLARE @s VARCHAR (MAX) = 'google COM '-' goolge.com 'DECLARE @ MD5 Binari (16) = Hashbites (' MD5 ', @s) DECLARE @ one binary (4) = convert (binary (4), reverse (convert (binary (4) , LEFT (@ MD5, 4)) DECLARE @ B Binari (2) = Convert (Binari (2), Reverse (Convert (Binari (2), Wright (@ MD5, 12)) DECLARE @ C Binary ( 2) = Convert (Binari (2), Reverse (converter (Binari (2), Wright (@ MD5, 10)) DECLARE @ D Binari (8) = Convert (Binari (8), Wright (@ MD5, 8)) convert Vert (UNIQUEIDENTIFIER, @ A + B + @ C + @ D)   

Returns D86B5A7F-7A25-4895-A6D0-63BA3A706627

I can do all three To create the same value, we convert to an int64, but the GUID is bothering me.

If you correct the spelling of google in your SQL instance (this is goolge in your post), you get the correct result.

Cannot fix the select/delete function. PHP/MySQL/JavaScript -


I have the following script for adding, editing and deleting mysql in friends, and showing it on the index.php file Used to be. So here is my index.php file:

  & lt; Script & gt; Function goDel () {var recslen = document.forms [0]. Length; Var checkbox = "" (i = 1; i  gt; {var con = confirm ("Are you sure you want to delete"); If (con) {document.forms [0] .action = "delete.php? Recsno =" checkbox document.forms [0]. Submit ()}} and {warnings ("no record has been selected.")}} Select function () {// var formname = document.getElementById (formname); Var recslen = document.forms [0]. Length; If (document.forms [0] .topcheckbox.checked == true) {for (i = 1; i  gt; & Lt; TR & gt; & Lt; Td> & Lt; Hour size = "1" node & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; Form action = "" method = "post" name = "" id = "" & gt; & Lt; Width of the table = "600" border = "1" align = "center" cellpadding = "2" cell area = "2" & gt; & Lt; TR & gt; & Lt; Td> & Lt; Input name = "top checkbox" type = "checkbox" class = "check" id = "top checkbox" onClick = "selectall ();" Value = "on" & gt; Select all & lt; / Td> & Lt; Td colspan = "3" align = "center" & gt; & Lt; A href = "form.php? Mode = addition" & gt; Add new branch & lt; / A & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td> & Lt; Strong & gt; & Lt; A href = "javascript: goDel ()" & gt; Remove & lt; / A & gt; & Lt; / Strong> & Lt; / Td> & Lt; Td> & Lt; Strong & gt; Branch name & lt; / Strong> & Lt; / Td> & Lt; Td> & Lt; Strong & gt; Small name & lt; / Strong> & Lt; / Td> & Lt; TD & gt; & Lt; Strong> Update & lt; / Strong> & Lt; / TD & gt; & Lt; / TR & gt; By & lt;? Included ("conn.php"); $ Sql ​​= "Brand name by SOR, choose short name from branch name $ $; $ result = mysql_query ($ sql, $ connection) or die (mysql_error ()); while ($ line = mysql_fetch_array ($ result)) { ? & Gt; & lt; tr & gt; & lt; td & gt; & lt; input name = "& lt;? Echo $ row ['sn'] ;? & Gt; "Type =" checkbox "class =" check "& gt; & lt; / td> & lt; td & gt; & lt ;? echo per line ['branchname'];? & Gt; Lt; / td & gt; & lt; td & gt; & lt;? Echo per line ['short-n'];? & Gt; & lt; / td> gt; & lt; td & gt; & lt; ; A href = "& lt;? Echo "form.php? Sn =". $ Line ['sn']. "& Amp; mode = update";; & Gt; Updates & lt; / a & gt; & lt; / TD & gt; & lt; / tr & gt; k   

This is my delete.php file :

  & lt ;? php included ("conn.php"); $ Recsno = $ _ receive ["recsno"]; $ data = trim ($ recsno); $ Ex = explosion {$ Id = trim ($ ex [$ i] for $ ($ "$"); $ size = sizeof ($ east); ($ i = 0; $ i & lt; $ size; $ i ++) ); $ Sql ​​= "Remove from branch where sn = '$ id'"; $ result = mysql_query ($ sql, $ connection) or die (mysql_error ());} header ("location: index.php" );? & Gt;   

The problem is that When I check the 1 line and click Delete, it is removing all the rows, like I clicked on selecting all (which I did not do). Thank you in advance.

It looks like the query is not getting the value of $ id $ Id .

Just get the id value

  $ id = $ _REQUEST ["SN"];   

Then delete your query

  $ sql = "$ branch, where sn = '$ id'";    

ios - Programmatically turn off VoiceProcessingIO AGC -


I am using Apple's CoreAudio Framework to record my microphone feed. Automatic gain control seems enabled by default:

  kAUVoiceIOProperty_VoiceProcessingEnableAGC indicates that automatic gain control is enabled (any non-pricing value) or disabled (value of 0) Is capable of form. The value is to read / write UINT 32 on the global audio unit area. Available in OS X v10.7 and later. Declared in AudioUnitProperties.h   

How can I programmatically stop the AGC in CoreAds?

Assume that you voiceprocessor

  UInt32 is using an AUVoiceProcessor Audio Unit named turnoff = 0; Audio UNNet ProPorty (Voice Processor, KUIvoiceOoProperty_VisProsaging ANALACC, QDOUnitScope_GLOBAL, 0, and Turnoff, Safeoff (Turnoff));   

Quick Details: What is doing this is setting Properties on 0 on the audio unit, which in this case disables AGC in the audio units usually There are two sets of controllable values ​​named Properties and Parameters . You can assign these values ​​to AudioUnitSetProperty () / AudioUnitGetProperty () And AudioUnitSetParameter () / can be set / received using the AudioUnitGetParameter () accordingly accordingly.

Note: You should probably check the OSStatus code that AudioUnitSetProperty () returns (this will be equal to noErr if There was no error).

Having issue with PHP URL Redirect Between Multiple Domains -


I have a lack of PHP skills and I have tried to troubleshoot this problem for a while and answered with no luck Have not searched. .. and I'm sure this is something easy.

I have a page on a domain that is checking to see if a cookie exists, and if it is not, then it sends a completely different domain to the user at birth date. Once they enter it and enter it for more than 21 years, they take it back to the original domain, but for some reason my script is not the whole thing, only on the sub-directory of the reference domain Occupation Defense is doing.

Then, the user goes to a fictional URL, abc.com, on the following page:

  & lt ;? Php function over21 () {session_start (); $ REDIRECT_URL = 'http: //xyz.com'; $ Valid = false; If (! $ ($ _COOKIE ["over21"])) {$ validated = true; } If (! $ Valid and released ($ _ session ['over21'])) {$ validated = true; } If ($ valid) {return; } And {$ redirect_url = $ redirect_url} "? Return =". $ _ Server ['REQUEST_URI']; Header ('Location:' $ Redirect_url); Exit (0); }} Over 21 (); ? & Gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Abc.com page & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; Before you can read this content, you will be taken to xyz.com to validate your age & lt; / Body & gt; & Lt; / Html & gt;   

So far so good, now they are sent to xyz.com to enter the date of birth:

   = 21) {Setsuke ("over 21", $ value, time (+ 3600 * 24); $ _SESSION ['over21'] = 1; ? $ = Isset ($ _ receive ['return']) urldecode ($ _ receive ['return']) redirect: './'; Header ("Location:". $ Redirect); Go out; } And {$ _SESSION ['under21'] = 0; Header ("Location: http://google.com"); Go out; }}? & Gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; This is xyz.com & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form & gt; Here is a form with input and to collect such days, months and years of birth. & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt;   

If I have an age verification piece and reference page on the same domain then the script is doing a great job. But how can I modify it so that the age verification page belongs to the domain of reference Capturing full URL, not just subdomain?

Therefore, I think ignoring the same basic comment, just by looking at the session start code, It seems that you were trying to share a session across the domain.

See what you are asking only about me.

'REQUEST_URI' - given the URI to access this page; For example, '/index.html'

Try the HTTP_HOST instead.

similarly:

c# - How to add a listViewItem with its own unique image -


Available to add an entry in the ListView C # add Apment methods

  public virtual List View (ListViewItem value) to public virtual ListViewItem (string text) Add public virtual ListViewItem (string text, int imageIndex) Add public virtual ListViewItem (string text string ImageKey) Add public virtual ListViewItem (string key, string text, integer imageIndex) Sir Form on virtual ListViewItem (String key, String text, add string ImageKey)   

Landscape: I ListViewItems with its unique images have a ListView and dynamic as before Columns want to add.

Question: How would you do this?

code I am working

  private void AddToMyList (SomeDataType message) {string Entrykey = message.ID; // Add your 1 column parameter string [] rowEntry = new string [1]; Line entry [0] = message.name; // make it a list view and its line list is indicated by the listITImline = new list view (line entry, (deviceListView.Items.Count- 1)); // Tag the row entry as unique ID line. Tag = Entrykey; // Add the image to the first column row. Image index = 0; // If the image is given for the project then add the image. Images (ENTERTAINMENT, MESSAGES. MARKERMARKER IKON); / LISTView.Items.Add (line) Add the type of lookup to device list at the end;    

There are two things that you need to do

    < Li> Add an image to the image list if it is not already
  • Create a new ListViewItem and assign it an image from the previous point

    This can be done this way based on your code:

      // add marker icons Antrki imagelistforTypeIcons.Images.Add for image insertion (Entrykey, message.marker.markerIcon); // Use the icon from ImageList which is stored under the Entrykey ListViewItem line = New ListViewItem (rowEntry); Line. Images = Entry; // whatever you need a row later. Tag = Entry; ....   

    In the problem with your code (without really trying to do it) you are specifying in the ImageIndex .

    • You are adding a new image to an image list, but assigning an image to a ListViewRow from a different one
    • You You are providing the image index in the constructor but setting it later 0 (why?)
    • You are providing the wrong image index in the first place, because the image in the image list before you add a new image The index of is calculated.

      If your code can be cured in this way:

        // markerIcon Entrykey imagelistforTypeIcons.Images.Add (Entrykey, message.marker.markerIcon) Pair in ImageList; // Use the icon from ImageList which is stored under the Entrykey ListViewItem line = New ListViewItem (rowEntry); Line. Image Index = Type for Icons.Count- 1; // whatever you need a row later. Tag = Entry;    

ios - Positioning GMSMapView to show multiple annotations at once -


My question is quite similar How can I do the same process (Maps to fit all annotations / markers on the screen Can be resized once) with Google Maps? As I have understood that I want to convert MK Cordinet Region to GMSPOction, is my way right?

is very simple, just:

  @ property (non-standard, Strong) gmmapview * mapview; - (zero) did the FitbusinessWithmarker: (NSARRA *) Marker {GMS Cordined Bounds * Bounds = [[GMSCordinate Boundes Elok] Init] ;; (GMS marker * marker in markers) {Bound = [including limitations: marker.Search]; } GMSCameraUpdate * update = [GMSCameraUpdate Fitbound: border]; [M.MapeWeb moves camera: updates]; [Self. MapView animateToViewingAngle: 50]; }